documentation.d.ts 3.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843
  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 in a remote file
  11050. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11051. * @param url defines the url to load from
  11052. * @param scene defines the hosting scene
  11053. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11054. * @returns a promise that will resolve to the new sprite manager
  11055. */
  11056. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11057. /**
  11058. * Creates a sprite manager from a snippet saved by the sprite editor
  11059. * @param snippetId defines the snippet to load
  11060. * @param scene defines the hosting scene
  11061. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11062. * @returns a promise that will resolve to the new sprite manager
  11063. */
  11064. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11065. }
  11066. }
  11067. declare module BABYLON {
  11068. /** Interface used by value gradients (color, factor, ...) */
  11069. export interface IValueGradient {
  11070. /**
  11071. * Gets or sets the gradient value (between 0 and 1)
  11072. */
  11073. gradient: number;
  11074. }
  11075. /** Class used to store color4 gradient */
  11076. export class ColorGradient implements IValueGradient {
  11077. /**
  11078. * Gets or sets the gradient value (between 0 and 1)
  11079. */
  11080. gradient: number;
  11081. /**
  11082. * Gets or sets first associated color
  11083. */
  11084. color1: Color4;
  11085. /**
  11086. * Gets or sets second associated color
  11087. */
  11088. color2?: Color4 | undefined;
  11089. /**
  11090. * Creates a new color4 gradient
  11091. * @param gradient gets or sets the gradient value (between 0 and 1)
  11092. * @param color1 gets or sets first associated color
  11093. * @param color2 gets or sets first second color
  11094. */
  11095. constructor(
  11096. /**
  11097. * Gets or sets the gradient value (between 0 and 1)
  11098. */
  11099. gradient: number,
  11100. /**
  11101. * Gets or sets first associated color
  11102. */
  11103. color1: Color4,
  11104. /**
  11105. * Gets or sets second associated color
  11106. */
  11107. color2?: Color4 | undefined);
  11108. /**
  11109. * Will get a color picked randomly between color1 and color2.
  11110. * If color2 is undefined then color1 will be used
  11111. * @param result defines the target Color4 to store the result in
  11112. */
  11113. getColorToRef(result: Color4): void;
  11114. }
  11115. /** Class used to store color 3 gradient */
  11116. export class Color3Gradient implements IValueGradient {
  11117. /**
  11118. * Gets or sets the gradient value (between 0 and 1)
  11119. */
  11120. gradient: number;
  11121. /**
  11122. * Gets or sets the associated color
  11123. */
  11124. color: Color3;
  11125. /**
  11126. * Creates a new color3 gradient
  11127. * @param gradient gets or sets the gradient value (between 0 and 1)
  11128. * @param color gets or sets associated color
  11129. */
  11130. constructor(
  11131. /**
  11132. * Gets or sets the gradient value (between 0 and 1)
  11133. */
  11134. gradient: number,
  11135. /**
  11136. * Gets or sets the associated color
  11137. */
  11138. color: Color3);
  11139. }
  11140. /** Class used to store factor gradient */
  11141. export class FactorGradient implements IValueGradient {
  11142. /**
  11143. * Gets or sets the gradient value (between 0 and 1)
  11144. */
  11145. gradient: number;
  11146. /**
  11147. * Gets or sets first associated factor
  11148. */
  11149. factor1: number;
  11150. /**
  11151. * Gets or sets second associated factor
  11152. */
  11153. factor2?: number | undefined;
  11154. /**
  11155. * Creates a new factor gradient
  11156. * @param gradient gets or sets the gradient value (between 0 and 1)
  11157. * @param factor1 gets or sets first associated factor
  11158. * @param factor2 gets or sets second associated factor
  11159. */
  11160. constructor(
  11161. /**
  11162. * Gets or sets the gradient value (between 0 and 1)
  11163. */
  11164. gradient: number,
  11165. /**
  11166. * Gets or sets first associated factor
  11167. */
  11168. factor1: number,
  11169. /**
  11170. * Gets or sets second associated factor
  11171. */
  11172. factor2?: number | undefined);
  11173. /**
  11174. * Will get a number picked randomly between factor1 and factor2.
  11175. * If factor2 is undefined then factor1 will be used
  11176. * @returns the picked number
  11177. */
  11178. getFactor(): number;
  11179. }
  11180. /**
  11181. * Helper used to simplify some generic gradient tasks
  11182. */
  11183. export class GradientHelper {
  11184. /**
  11185. * Gets the current gradient from an array of IValueGradient
  11186. * @param ratio defines the current ratio to get
  11187. * @param gradients defines the array of IValueGradient
  11188. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11189. */
  11190. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11191. }
  11192. }
  11193. declare module BABYLON {
  11194. interface ThinEngine {
  11195. /**
  11196. * Creates a dynamic texture
  11197. * @param width defines the width of the texture
  11198. * @param height defines the height of the texture
  11199. * @param generateMipMaps defines if the engine should generate the mip levels
  11200. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11201. * @returns the dynamic texture inside an InternalTexture
  11202. */
  11203. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11204. /**
  11205. * Update the content of a dynamic texture
  11206. * @param texture defines the texture to update
  11207. * @param canvas defines the canvas containing the source
  11208. * @param invertY defines if data must be stored with Y axis inverted
  11209. * @param premulAlpha defines if alpha is stored as premultiplied
  11210. * @param format defines the format of the data
  11211. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11212. */
  11213. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11214. }
  11215. }
  11216. declare module BABYLON {
  11217. /**
  11218. * Helper class used to generate a canvas to manipulate images
  11219. */
  11220. export class CanvasGenerator {
  11221. /**
  11222. * Create a new canvas (or offscreen canvas depending on the context)
  11223. * @param width defines the expected width
  11224. * @param height defines the expected height
  11225. * @return a new canvas or offscreen canvas
  11226. */
  11227. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11228. }
  11229. }
  11230. declare module BABYLON {
  11231. /**
  11232. * A class extending Texture allowing drawing on a texture
  11233. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11234. */
  11235. export class DynamicTexture extends Texture {
  11236. private _generateMipMaps;
  11237. private _canvas;
  11238. private _context;
  11239. /**
  11240. * Creates a DynamicTexture
  11241. * @param name defines the name of the texture
  11242. * @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
  11243. * @param scene defines the scene where you want the texture
  11244. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11245. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11246. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11247. */
  11248. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11249. /**
  11250. * Get the current class name of the texture useful for serialization or dynamic coding.
  11251. * @returns "DynamicTexture"
  11252. */
  11253. getClassName(): string;
  11254. /**
  11255. * Gets the current state of canRescale
  11256. */
  11257. get canRescale(): boolean;
  11258. private _recreate;
  11259. /**
  11260. * Scales the texture
  11261. * @param ratio the scale factor to apply to both width and height
  11262. */
  11263. scale(ratio: number): void;
  11264. /**
  11265. * Resizes the texture
  11266. * @param width the new width
  11267. * @param height the new height
  11268. */
  11269. scaleTo(width: number, height: number): void;
  11270. /**
  11271. * Gets the context of the canvas used by the texture
  11272. * @returns the canvas context of the dynamic texture
  11273. */
  11274. getContext(): CanvasRenderingContext2D;
  11275. /**
  11276. * Clears the texture
  11277. */
  11278. clear(): void;
  11279. /**
  11280. * Updates the texture
  11281. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11282. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11283. */
  11284. update(invertY?: boolean, premulAlpha?: boolean): void;
  11285. /**
  11286. * Draws text onto the texture
  11287. * @param text defines the text to be drawn
  11288. * @param x defines the placement of the text from the left
  11289. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11290. * @param font defines the font to be used with font-style, font-size, font-name
  11291. * @param color defines the color used for the text
  11292. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11293. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11294. * @param update defines whether texture is immediately update (default is true)
  11295. */
  11296. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11297. /**
  11298. * Clones the texture
  11299. * @returns the clone of the texture.
  11300. */
  11301. clone(): DynamicTexture;
  11302. /**
  11303. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11304. * @returns a serialized dynamic texture object
  11305. */
  11306. serialize(): any;
  11307. /** @hidden */
  11308. _rebuild(): void;
  11309. }
  11310. }
  11311. declare module BABYLON {
  11312. interface ThinEngine {
  11313. /**
  11314. * Creates a raw texture
  11315. * @param data defines the data to store in the texture
  11316. * @param width defines the width of the texture
  11317. * @param height defines the height of the texture
  11318. * @param format defines the format of the data
  11319. * @param generateMipMaps defines if the engine should generate the mip levels
  11320. * @param invertY defines if data must be stored with Y axis inverted
  11321. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11322. * @param compression defines the compression used (null by default)
  11323. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11324. * @returns the raw texture inside an InternalTexture
  11325. */
  11326. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11327. /**
  11328. * Update a raw texture
  11329. * @param texture defines the texture to update
  11330. * @param data defines the data to store in the texture
  11331. * @param format defines the format of the data
  11332. * @param invertY defines if data must be stored with Y axis inverted
  11333. */
  11334. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11335. /**
  11336. * Update a raw texture
  11337. * @param texture defines the texture to update
  11338. * @param data defines the data to store in the texture
  11339. * @param format defines the format of the data
  11340. * @param invertY defines if data must be stored with Y axis inverted
  11341. * @param compression defines the compression used (null by default)
  11342. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11343. */
  11344. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11345. /**
  11346. * Creates a new raw cube texture
  11347. * @param data defines the array of data to use to create each face
  11348. * @param size defines the size of the textures
  11349. * @param format defines the format of the data
  11350. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11351. * @param generateMipMaps defines if the engine should generate the mip levels
  11352. * @param invertY defines if data must be stored with Y axis inverted
  11353. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11354. * @param compression defines the compression used (null by default)
  11355. * @returns the cube texture as an InternalTexture
  11356. */
  11357. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  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. */
  11366. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11367. /**
  11368. * Update a raw cube texture
  11369. * @param texture defines the texture to udpdate
  11370. * @param data defines the data to store
  11371. * @param format defines the data format
  11372. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11373. * @param invertY defines if data must be stored with Y axis inverted
  11374. * @param compression defines the compression used (null by default)
  11375. */
  11376. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11377. /**
  11378. * Update a raw cube texture
  11379. * @param texture defines the texture to udpdate
  11380. * @param data defines the data to store
  11381. * @param format defines the data format
  11382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11383. * @param invertY defines if data must be stored with Y axis inverted
  11384. * @param compression defines the compression used (null by default)
  11385. * @param level defines which level of the texture to update
  11386. */
  11387. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11388. /**
  11389. * Creates a new raw cube texture from a specified url
  11390. * @param url defines the url where the data is located
  11391. * @param scene defines the current scene
  11392. * @param size defines the size of the textures
  11393. * @param format defines the format of the data
  11394. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11395. * @param noMipmap defines if the engine should avoid generating the mip levels
  11396. * @param callback defines a callback used to extract texture data from loaded data
  11397. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11398. * @param onLoad defines a callback called when texture is loaded
  11399. * @param onError defines a callback called if there is an error
  11400. * @returns the cube texture as an InternalTexture
  11401. */
  11402. 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;
  11403. /**
  11404. * Creates a new raw cube texture from a specified url
  11405. * @param url defines the url where the data is located
  11406. * @param scene defines the current scene
  11407. * @param size defines the size of the textures
  11408. * @param format defines the format of the data
  11409. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11410. * @param noMipmap defines if the engine should avoid generating the mip levels
  11411. * @param callback defines a callback used to extract texture data from loaded data
  11412. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11413. * @param onLoad defines a callback called when texture is loaded
  11414. * @param onError defines a callback called if there is an error
  11415. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11416. * @param invertY defines if data must be stored with Y axis inverted
  11417. * @returns the cube texture as an InternalTexture
  11418. */
  11419. 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;
  11420. /**
  11421. * Creates a new raw 3D texture
  11422. * @param data defines the data used to create the texture
  11423. * @param width defines the width of the texture
  11424. * @param height defines the height of the texture
  11425. * @param depth defines the depth of the texture
  11426. * @param format defines the format of the texture
  11427. * @param generateMipMaps defines if the engine must generate mip levels
  11428. * @param invertY defines if data must be stored with Y axis inverted
  11429. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11430. * @param compression defines the compressed used (can be null)
  11431. * @param textureType defines the compressed used (can be null)
  11432. * @returns a new raw 3D texture (stored in an InternalTexture)
  11433. */
  11434. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11435. /**
  11436. * Update a raw 3D texture
  11437. * @param texture defines the texture to update
  11438. * @param data defines the data to store
  11439. * @param format defines the data format
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. */
  11442. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11443. /**
  11444. * Update a raw 3D texture
  11445. * @param texture defines the texture to update
  11446. * @param data defines the data to store
  11447. * @param format defines the data format
  11448. * @param invertY defines if data must be stored with Y axis inverted
  11449. * @param compression defines the used compression (can be null)
  11450. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11451. */
  11452. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11453. /**
  11454. * Creates a new raw 2D array texture
  11455. * @param data defines the data used to create the texture
  11456. * @param width defines the width of the texture
  11457. * @param height defines the height of the texture
  11458. * @param depth defines the number of layers of the texture
  11459. * @param format defines the format of the texture
  11460. * @param generateMipMaps defines if the engine must generate mip levels
  11461. * @param invertY defines if data must be stored with Y axis inverted
  11462. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11463. * @param compression defines the compressed used (can be null)
  11464. * @param textureType defines the compressed used (can be null)
  11465. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11466. */
  11467. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11468. /**
  11469. * Update a raw 2D array texture
  11470. * @param texture defines the texture to update
  11471. * @param data defines the data to store
  11472. * @param format defines the data format
  11473. * @param invertY defines if data must be stored with Y axis inverted
  11474. */
  11475. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11476. /**
  11477. * Update a raw 2D array texture
  11478. * @param texture defines the texture to update
  11479. * @param data defines the data to store
  11480. * @param format defines the data format
  11481. * @param invertY defines if data must be stored with Y axis inverted
  11482. * @param compression defines the used compression (can be null)
  11483. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11484. */
  11485. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11486. }
  11487. }
  11488. declare module BABYLON {
  11489. /**
  11490. * Raw texture can help creating a texture directly from an array of data.
  11491. * This can be super useful if you either get the data from an uncompressed source or
  11492. * if you wish to create your texture pixel by pixel.
  11493. */
  11494. export class RawTexture extends Texture {
  11495. /**
  11496. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11497. */
  11498. format: number;
  11499. /**
  11500. * Instantiates a new RawTexture.
  11501. * Raw texture can help creating a texture directly from an array of data.
  11502. * This can be super useful if you either get the data from an uncompressed source or
  11503. * if you wish to create your texture pixel by pixel.
  11504. * @param data define the array of data to use to create the texture
  11505. * @param width define the width of the texture
  11506. * @param height define the height of the texture
  11507. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11508. * @param scene define the scene the texture belongs to
  11509. * @param generateMipMaps define whether mip maps should be generated or not
  11510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11512. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11513. */
  11514. constructor(data: ArrayBufferView, width: number, height: number,
  11515. /**
  11516. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11517. */
  11518. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11519. /**
  11520. * Updates the texture underlying data.
  11521. * @param data Define the new data of the texture
  11522. */
  11523. update(data: ArrayBufferView): void;
  11524. /**
  11525. * Creates a luminance texture from some data.
  11526. * @param data Define the texture data
  11527. * @param width Define the width of the texture
  11528. * @param height Define the height of the texture
  11529. * @param scene Define the scene the texture belongs to
  11530. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11531. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11532. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11533. * @returns the luminance texture
  11534. */
  11535. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11536. /**
  11537. * Creates a luminance alpha texture from some data.
  11538. * @param data Define the texture data
  11539. * @param width Define the width of the texture
  11540. * @param height Define the height of the texture
  11541. * @param scene Define the scene the texture belongs to
  11542. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11543. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11544. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11545. * @returns the luminance alpha texture
  11546. */
  11547. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11548. /**
  11549. * Creates an alpha texture from some data.
  11550. * @param data Define the texture data
  11551. * @param width Define the width of the texture
  11552. * @param height Define the height of the texture
  11553. * @param scene Define the scene the texture belongs to
  11554. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11555. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11556. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11557. * @returns the alpha texture
  11558. */
  11559. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11560. /**
  11561. * Creates a RGB texture from some data.
  11562. * @param data Define the texture data
  11563. * @param width Define the width of the texture
  11564. * @param height Define the height of the texture
  11565. * @param scene Define the scene the texture belongs to
  11566. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11567. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11568. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11569. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11570. * @returns the RGB alpha texture
  11571. */
  11572. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11573. /**
  11574. * Creates a RGBA texture from some data.
  11575. * @param data Define the texture data
  11576. * @param width Define the width of the texture
  11577. * @param height Define the height of the texture
  11578. * @param scene Define the scene the texture belongs to
  11579. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11582. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11583. * @returns the RGBA texture
  11584. */
  11585. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11586. /**
  11587. * Creates a R texture from some data.
  11588. * @param data Define the texture data
  11589. * @param width Define the width of the texture
  11590. * @param height Define the height of the texture
  11591. * @param scene Define the scene the texture belongs to
  11592. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11593. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11594. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11595. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11596. * @returns the R texture
  11597. */
  11598. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11599. }
  11600. }
  11601. declare module BABYLON {
  11602. interface AbstractScene {
  11603. /**
  11604. * The list of procedural textures added to the scene
  11605. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11606. */
  11607. proceduralTextures: Array<ProceduralTexture>;
  11608. }
  11609. /**
  11610. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11611. * in a given scene.
  11612. */
  11613. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11614. /**
  11615. * The component name helpfull to identify the component in the list of scene components.
  11616. */
  11617. readonly name: string;
  11618. /**
  11619. * The scene the component belongs to.
  11620. */
  11621. scene: Scene;
  11622. /**
  11623. * Creates a new instance of the component for the given scene
  11624. * @param scene Defines the scene to register the component in
  11625. */
  11626. constructor(scene: Scene);
  11627. /**
  11628. * Registers the component in a given scene
  11629. */
  11630. register(): void;
  11631. /**
  11632. * Rebuilds the elements related to this component in case of
  11633. * context lost for instance.
  11634. */
  11635. rebuild(): void;
  11636. /**
  11637. * Disposes the component and the associated ressources.
  11638. */
  11639. dispose(): void;
  11640. private _beforeClear;
  11641. }
  11642. }
  11643. declare module BABYLON {
  11644. interface ThinEngine {
  11645. /**
  11646. * Creates a new render target cube texture
  11647. * @param size defines the size of the texture
  11648. * @param options defines the options used to create the texture
  11649. * @returns a new render target cube texture stored in an InternalTexture
  11650. */
  11651. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11652. }
  11653. }
  11654. declare module BABYLON {
  11655. /** @hidden */
  11656. export var proceduralVertexShader: {
  11657. name: string;
  11658. shader: string;
  11659. };
  11660. }
  11661. declare module BABYLON {
  11662. /**
  11663. * 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.
  11664. * This is the base class of any Procedural texture and contains most of the shareable code.
  11665. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11666. */
  11667. export class ProceduralTexture extends Texture {
  11668. isCube: boolean;
  11669. /**
  11670. * Define if the texture is enabled or not (disabled texture will not render)
  11671. */
  11672. isEnabled: boolean;
  11673. /**
  11674. * Define if the texture must be cleared before rendering (default is true)
  11675. */
  11676. autoClear: boolean;
  11677. /**
  11678. * Callback called when the texture is generated
  11679. */
  11680. onGenerated: () => void;
  11681. /**
  11682. * Event raised when the texture is generated
  11683. */
  11684. onGeneratedObservable: Observable<ProceduralTexture>;
  11685. /** @hidden */
  11686. _generateMipMaps: boolean;
  11687. /** @hidden **/
  11688. _effect: Effect;
  11689. /** @hidden */
  11690. _textures: {
  11691. [key: string]: Texture;
  11692. };
  11693. /** @hidden */
  11694. protected _fallbackTexture: Nullable<Texture>;
  11695. private _size;
  11696. private _currentRefreshId;
  11697. private _frameId;
  11698. private _refreshRate;
  11699. private _vertexBuffers;
  11700. private _indexBuffer;
  11701. private _uniforms;
  11702. private _samplers;
  11703. private _fragment;
  11704. private _floats;
  11705. private _ints;
  11706. private _floatsArrays;
  11707. private _colors3;
  11708. private _colors4;
  11709. private _vectors2;
  11710. private _vectors3;
  11711. private _matrices;
  11712. private _fallbackTextureUsed;
  11713. private _fullEngine;
  11714. private _cachedDefines;
  11715. private _contentUpdateId;
  11716. private _contentData;
  11717. /**
  11718. * Instantiates a new procedural texture.
  11719. * 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.
  11720. * This is the base class of any Procedural texture and contains most of the shareable code.
  11721. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11722. * @param name Define the name of the texture
  11723. * @param size Define the size of the texture to create
  11724. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11725. * @param scene Define the scene the texture belongs to
  11726. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11727. * @param generateMipMaps Define if the texture should creates mip maps or not
  11728. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11729. */
  11730. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11731. /**
  11732. * The effect that is created when initializing the post process.
  11733. * @returns The created effect corresponding the the postprocess.
  11734. */
  11735. getEffect(): Effect;
  11736. /**
  11737. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11738. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11739. */
  11740. getContent(): Nullable<ArrayBufferView>;
  11741. private _createIndexBuffer;
  11742. /** @hidden */
  11743. _rebuild(): void;
  11744. /**
  11745. * Resets the texture in order to recreate its associated resources.
  11746. * This can be called in case of context loss
  11747. */
  11748. reset(): void;
  11749. protected _getDefines(): string;
  11750. /**
  11751. * Is the texture ready to be used ? (rendered at least once)
  11752. * @returns true if ready, otherwise, false.
  11753. */
  11754. isReady(): boolean;
  11755. /**
  11756. * Resets the refresh counter of the texture and start bak from scratch.
  11757. * Could be useful to regenerate the texture if it is setup to render only once.
  11758. */
  11759. resetRefreshCounter(): void;
  11760. /**
  11761. * Set the fragment shader to use in order to render the texture.
  11762. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11763. */
  11764. setFragment(fragment: any): void;
  11765. /**
  11766. * Define the refresh rate of the texture or the rendering frequency.
  11767. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11768. */
  11769. get refreshRate(): number;
  11770. set refreshRate(value: number);
  11771. /** @hidden */
  11772. _shouldRender(): boolean;
  11773. /**
  11774. * Get the size the texture is rendering at.
  11775. * @returns the size (texture is always squared)
  11776. */
  11777. getRenderSize(): number;
  11778. /**
  11779. * Resize the texture to new value.
  11780. * @param size Define the new size the texture should have
  11781. * @param generateMipMaps Define whether the new texture should create mip maps
  11782. */
  11783. resize(size: number, generateMipMaps: boolean): void;
  11784. private _checkUniform;
  11785. /**
  11786. * Set a texture in the shader program used to render.
  11787. * @param name Define the name of the uniform samplers as defined in the shader
  11788. * @param texture Define the texture to bind to this sampler
  11789. * @return the texture itself allowing "fluent" like uniform updates
  11790. */
  11791. setTexture(name: string, texture: Texture): ProceduralTexture;
  11792. /**
  11793. * Set a float in the shader.
  11794. * @param name Define the name of the uniform as defined in the shader
  11795. * @param value Define the value to give to the uniform
  11796. * @return the texture itself allowing "fluent" like uniform updates
  11797. */
  11798. setFloat(name: string, value: number): ProceduralTexture;
  11799. /**
  11800. * Set a int in the shader.
  11801. * @param name Define the name of the uniform as defined in the shader
  11802. * @param value Define the value to give to the uniform
  11803. * @return the texture itself allowing "fluent" like uniform updates
  11804. */
  11805. setInt(name: string, value: number): ProceduralTexture;
  11806. /**
  11807. * Set an array of floats in the shader.
  11808. * @param name Define the name of the uniform as defined in the shader
  11809. * @param value Define the value to give to the uniform
  11810. * @return the texture itself allowing "fluent" like uniform updates
  11811. */
  11812. setFloats(name: string, value: number[]): ProceduralTexture;
  11813. /**
  11814. * Set a vec3 in the shader from a Color3.
  11815. * @param name Define the name of the uniform as defined in the shader
  11816. * @param value Define the value to give to the uniform
  11817. * @return the texture itself allowing "fluent" like uniform updates
  11818. */
  11819. setColor3(name: string, value: Color3): ProceduralTexture;
  11820. /**
  11821. * Set a vec4 in the shader from a Color4.
  11822. * @param name Define the name of the uniform as defined in the shader
  11823. * @param value Define the value to give to the uniform
  11824. * @return the texture itself allowing "fluent" like uniform updates
  11825. */
  11826. setColor4(name: string, value: Color4): ProceduralTexture;
  11827. /**
  11828. * Set a vec2 in the shader from a Vector2.
  11829. * @param name Define the name of the uniform as defined in the shader
  11830. * @param value Define the value to give to the uniform
  11831. * @return the texture itself allowing "fluent" like uniform updates
  11832. */
  11833. setVector2(name: string, value: Vector2): ProceduralTexture;
  11834. /**
  11835. * Set a vec3 in the shader from a Vector3.
  11836. * @param name Define the name of the uniform as defined in the shader
  11837. * @param value Define the value to give to the uniform
  11838. * @return the texture itself allowing "fluent" like uniform updates
  11839. */
  11840. setVector3(name: string, value: Vector3): ProceduralTexture;
  11841. /**
  11842. * Set a mat4 in the shader from a MAtrix.
  11843. * @param name Define the name of the uniform as defined in the shader
  11844. * @param value Define the value to give to the uniform
  11845. * @return the texture itself allowing "fluent" like uniform updates
  11846. */
  11847. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11848. /**
  11849. * Render the texture to its associated render target.
  11850. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11851. */
  11852. render(useCameraPostProcess?: boolean): void;
  11853. /**
  11854. * Clone the texture.
  11855. * @returns the cloned texture
  11856. */
  11857. clone(): ProceduralTexture;
  11858. /**
  11859. * Dispose the texture and release its asoociated resources.
  11860. */
  11861. dispose(): void;
  11862. }
  11863. }
  11864. declare module BABYLON {
  11865. /**
  11866. * This represents the base class for particle system in Babylon.
  11867. * 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.
  11868. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11869. * @example https://doc.babylonjs.com/babylon101/particles
  11870. */
  11871. export class BaseParticleSystem {
  11872. /**
  11873. * Source color is added to the destination color without alpha affecting the result
  11874. */
  11875. static BLENDMODE_ONEONE: number;
  11876. /**
  11877. * Blend current color and particle color using particle’s alpha
  11878. */
  11879. static BLENDMODE_STANDARD: number;
  11880. /**
  11881. * Add current color and particle color multiplied by particle’s alpha
  11882. */
  11883. static BLENDMODE_ADD: number;
  11884. /**
  11885. * Multiply current color with particle color
  11886. */
  11887. static BLENDMODE_MULTIPLY: number;
  11888. /**
  11889. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11890. */
  11891. static BLENDMODE_MULTIPLYADD: number;
  11892. /**
  11893. * List of animations used by the particle system.
  11894. */
  11895. animations: Animation[];
  11896. /**
  11897. * Gets or sets the unique id of the particle system
  11898. */
  11899. uniqueId: number;
  11900. /**
  11901. * The id of the Particle system.
  11902. */
  11903. id: string;
  11904. /**
  11905. * The friendly name of the Particle system.
  11906. */
  11907. name: string;
  11908. /**
  11909. * Snippet ID if the particle system was created from the snippet server
  11910. */
  11911. snippetId: string;
  11912. /**
  11913. * The rendering group used by the Particle system to chose when to render.
  11914. */
  11915. renderingGroupId: number;
  11916. /**
  11917. * The emitter represents the Mesh or position we are attaching the particle system to.
  11918. */
  11919. emitter: Nullable<AbstractMesh | Vector3>;
  11920. /**
  11921. * The maximum number of particles to emit per frame
  11922. */
  11923. emitRate: number;
  11924. /**
  11925. * If you want to launch only a few particles at once, that can be done, as well.
  11926. */
  11927. manualEmitCount: number;
  11928. /**
  11929. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11930. */
  11931. updateSpeed: number;
  11932. /**
  11933. * The amount of time the particle system is running (depends of the overall update speed).
  11934. */
  11935. targetStopDuration: number;
  11936. /**
  11937. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11938. */
  11939. disposeOnStop: boolean;
  11940. /**
  11941. * Minimum power of emitting particles.
  11942. */
  11943. minEmitPower: number;
  11944. /**
  11945. * Maximum power of emitting particles.
  11946. */
  11947. maxEmitPower: number;
  11948. /**
  11949. * Minimum life time of emitting particles.
  11950. */
  11951. minLifeTime: number;
  11952. /**
  11953. * Maximum life time of emitting particles.
  11954. */
  11955. maxLifeTime: number;
  11956. /**
  11957. * Minimum Size of emitting particles.
  11958. */
  11959. minSize: number;
  11960. /**
  11961. * Maximum Size of emitting particles.
  11962. */
  11963. maxSize: number;
  11964. /**
  11965. * Minimum scale of emitting particles on X axis.
  11966. */
  11967. minScaleX: number;
  11968. /**
  11969. * Maximum scale of emitting particles on X axis.
  11970. */
  11971. maxScaleX: number;
  11972. /**
  11973. * Minimum scale of emitting particles on Y axis.
  11974. */
  11975. minScaleY: number;
  11976. /**
  11977. * Maximum scale of emitting particles on Y axis.
  11978. */
  11979. maxScaleY: number;
  11980. /**
  11981. * Gets or sets the minimal initial rotation in radians.
  11982. */
  11983. minInitialRotation: number;
  11984. /**
  11985. * Gets or sets the maximal initial rotation in radians.
  11986. */
  11987. maxInitialRotation: number;
  11988. /**
  11989. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11990. */
  11991. minAngularSpeed: number;
  11992. /**
  11993. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11994. */
  11995. maxAngularSpeed: number;
  11996. /**
  11997. * The texture used to render each particle. (this can be a spritesheet)
  11998. */
  11999. particleTexture: Nullable<Texture>;
  12000. /**
  12001. * The layer mask we are rendering the particles through.
  12002. */
  12003. layerMask: number;
  12004. /**
  12005. * This can help using your own shader to render the particle system.
  12006. * The according effect will be created
  12007. */
  12008. customShader: any;
  12009. /**
  12010. * By default particle system starts as soon as they are created. This prevents the
  12011. * automatic start to happen and let you decide when to start emitting particles.
  12012. */
  12013. preventAutoStart: boolean;
  12014. private _noiseTexture;
  12015. /**
  12016. * Gets or sets a texture used to add random noise to particle positions
  12017. */
  12018. get noiseTexture(): Nullable<ProceduralTexture>;
  12019. set noiseTexture(value: Nullable<ProceduralTexture>);
  12020. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12021. noiseStrength: Vector3;
  12022. /**
  12023. * Callback triggered when the particle animation is ending.
  12024. */
  12025. onAnimationEnd: Nullable<() => void>;
  12026. /**
  12027. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12028. */
  12029. blendMode: number;
  12030. /**
  12031. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12032. * to override the particles.
  12033. */
  12034. forceDepthWrite: boolean;
  12035. /** 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 */
  12036. preWarmCycles: number;
  12037. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12038. preWarmStepOffset: number;
  12039. /**
  12040. * 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)
  12041. */
  12042. spriteCellChangeSpeed: number;
  12043. /**
  12044. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12045. */
  12046. startSpriteCellID: number;
  12047. /**
  12048. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12049. */
  12050. endSpriteCellID: number;
  12051. /**
  12052. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12053. */
  12054. spriteCellWidth: number;
  12055. /**
  12056. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12057. */
  12058. spriteCellHeight: number;
  12059. /**
  12060. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12061. */
  12062. spriteRandomStartCell: boolean;
  12063. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12064. translationPivot: Vector2;
  12065. /** @hidden */
  12066. protected _isAnimationSheetEnabled: boolean;
  12067. /**
  12068. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12069. */
  12070. beginAnimationOnStart: boolean;
  12071. /**
  12072. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12073. */
  12074. beginAnimationFrom: number;
  12075. /**
  12076. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12077. */
  12078. beginAnimationTo: number;
  12079. /**
  12080. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12081. */
  12082. beginAnimationLoop: boolean;
  12083. /**
  12084. * Gets or sets a world offset applied to all particles
  12085. */
  12086. worldOffset: Vector3;
  12087. /**
  12088. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12089. */
  12090. get isAnimationSheetEnabled(): boolean;
  12091. set isAnimationSheetEnabled(value: boolean);
  12092. /**
  12093. * Get hosting scene
  12094. * @returns the scene
  12095. */
  12096. getScene(): Scene;
  12097. /**
  12098. * You can use gravity if you want to give an orientation to your particles.
  12099. */
  12100. gravity: Vector3;
  12101. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12102. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12103. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12104. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12105. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12106. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12107. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12108. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12109. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12110. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12111. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12112. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12113. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12114. /**
  12115. * Defines the delay in milliseconds before starting the system (0 by default)
  12116. */
  12117. startDelay: number;
  12118. /**
  12119. * Gets the current list of drag gradients.
  12120. * You must use addDragGradient and removeDragGradient to udpate this list
  12121. * @returns the list of drag gradients
  12122. */
  12123. getDragGradients(): Nullable<Array<FactorGradient>>;
  12124. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12125. limitVelocityDamping: number;
  12126. /**
  12127. * Gets the current list of limit velocity gradients.
  12128. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12129. * @returns the list of limit velocity gradients
  12130. */
  12131. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12132. /**
  12133. * Gets the current list of color gradients.
  12134. * You must use addColorGradient and removeColorGradient to udpate this list
  12135. * @returns the list of color gradients
  12136. */
  12137. getColorGradients(): Nullable<Array<ColorGradient>>;
  12138. /**
  12139. * Gets the current list of size gradients.
  12140. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12141. * @returns the list of size gradients
  12142. */
  12143. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12144. /**
  12145. * Gets the current list of color remap gradients.
  12146. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12147. * @returns the list of color remap gradients
  12148. */
  12149. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12150. /**
  12151. * Gets the current list of alpha remap gradients.
  12152. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12153. * @returns the list of alpha remap gradients
  12154. */
  12155. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12156. /**
  12157. * Gets the current list of life time gradients.
  12158. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12159. * @returns the list of life time gradients
  12160. */
  12161. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12162. /**
  12163. * Gets the current list of angular speed gradients.
  12164. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12165. * @returns the list of angular speed gradients
  12166. */
  12167. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12168. /**
  12169. * Gets the current list of velocity gradients.
  12170. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12171. * @returns the list of velocity gradients
  12172. */
  12173. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12174. /**
  12175. * Gets the current list of start size gradients.
  12176. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12177. * @returns the list of start size gradients
  12178. */
  12179. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12180. /**
  12181. * Gets the current list of emit rate gradients.
  12182. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12183. * @returns the list of emit rate gradients
  12184. */
  12185. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12186. /**
  12187. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12188. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12189. */
  12190. get direction1(): Vector3;
  12191. set direction1(value: Vector3);
  12192. /**
  12193. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12194. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12195. */
  12196. get direction2(): Vector3;
  12197. set direction2(value: Vector3);
  12198. /**
  12199. * 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.
  12200. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12201. */
  12202. get minEmitBox(): Vector3;
  12203. set minEmitBox(value: Vector3);
  12204. /**
  12205. * 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.
  12206. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12207. */
  12208. get maxEmitBox(): Vector3;
  12209. set maxEmitBox(value: Vector3);
  12210. /**
  12211. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12212. */
  12213. color1: Color4;
  12214. /**
  12215. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12216. */
  12217. color2: Color4;
  12218. /**
  12219. * Color the particle will have at the end of its lifetime
  12220. */
  12221. colorDead: Color4;
  12222. /**
  12223. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12224. */
  12225. textureMask: Color4;
  12226. /**
  12227. * The particle emitter type defines the emitter used by the particle system.
  12228. * It can be for example box, sphere, or cone...
  12229. */
  12230. particleEmitterType: IParticleEmitterType;
  12231. /** @hidden */
  12232. _isSubEmitter: boolean;
  12233. /**
  12234. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12235. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12236. */
  12237. billboardMode: number;
  12238. protected _isBillboardBased: boolean;
  12239. /**
  12240. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12241. */
  12242. get isBillboardBased(): boolean;
  12243. set isBillboardBased(value: boolean);
  12244. /**
  12245. * The scene the particle system belongs to.
  12246. */
  12247. protected _scene: Scene;
  12248. /**
  12249. * Local cache of defines for image processing.
  12250. */
  12251. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12252. /**
  12253. * Default configuration related to image processing available in the standard Material.
  12254. */
  12255. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12256. /**
  12257. * Gets the image processing configuration used either in this material.
  12258. */
  12259. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12260. /**
  12261. * Sets the Default image processing configuration used either in the this material.
  12262. *
  12263. * If sets to null, the scene one is in use.
  12264. */
  12265. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12266. /**
  12267. * Attaches a new image processing configuration to the Standard Material.
  12268. * @param configuration
  12269. */
  12270. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12271. /** @hidden */
  12272. protected _reset(): void;
  12273. /** @hidden */
  12274. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12275. /**
  12276. * Instantiates a particle system.
  12277. * 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.
  12278. * @param name The name of the particle system
  12279. */
  12280. constructor(name: string);
  12281. /**
  12282. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12283. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12284. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12285. * @returns the emitter
  12286. */
  12287. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12288. /**
  12289. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12290. * @param radius The radius of the hemisphere to emit from
  12291. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12292. * @returns the emitter
  12293. */
  12294. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12295. /**
  12296. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12297. * @param radius The radius of the sphere to emit from
  12298. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12299. * @returns the emitter
  12300. */
  12301. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12302. /**
  12303. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12304. * @param radius The radius of the sphere to emit from
  12305. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12306. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12307. * @returns the emitter
  12308. */
  12309. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12310. /**
  12311. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12312. * @param radius The radius of the emission cylinder
  12313. * @param height The height of the emission cylinder
  12314. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12315. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12316. * @returns the emitter
  12317. */
  12318. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12319. /**
  12320. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12321. * @param radius The radius of the cylinder to emit from
  12322. * @param height The height of the emission cylinder
  12323. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12324. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12325. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12326. * @returns the emitter
  12327. */
  12328. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12329. /**
  12330. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12331. * @param radius The radius of the cone to emit from
  12332. * @param angle The base angle of the cone
  12333. * @returns the emitter
  12334. */
  12335. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12336. /**
  12337. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12338. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12339. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12340. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12341. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12342. * @returns the emitter
  12343. */
  12344. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12345. }
  12346. }
  12347. declare module BABYLON {
  12348. /**
  12349. * Type of sub emitter
  12350. */
  12351. export enum SubEmitterType {
  12352. /**
  12353. * Attached to the particle over it's lifetime
  12354. */
  12355. ATTACHED = 0,
  12356. /**
  12357. * Created when the particle dies
  12358. */
  12359. END = 1
  12360. }
  12361. /**
  12362. * Sub emitter class used to emit particles from an existing particle
  12363. */
  12364. export class SubEmitter {
  12365. /**
  12366. * the particle system to be used by the sub emitter
  12367. */
  12368. particleSystem: ParticleSystem;
  12369. /**
  12370. * Type of the submitter (Default: END)
  12371. */
  12372. type: SubEmitterType;
  12373. /**
  12374. * 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)
  12375. * Note: This only is supported when using an emitter of type Mesh
  12376. */
  12377. inheritDirection: boolean;
  12378. /**
  12379. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12380. */
  12381. inheritedVelocityAmount: number;
  12382. /**
  12383. * Creates a sub emitter
  12384. * @param particleSystem the particle system to be used by the sub emitter
  12385. */
  12386. constructor(
  12387. /**
  12388. * the particle system to be used by the sub emitter
  12389. */
  12390. particleSystem: ParticleSystem);
  12391. /**
  12392. * Clones the sub emitter
  12393. * @returns the cloned sub emitter
  12394. */
  12395. clone(): SubEmitter;
  12396. /**
  12397. * Serialize current object to a JSON object
  12398. * @returns the serialized object
  12399. */
  12400. serialize(): any;
  12401. /** @hidden */
  12402. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12403. /**
  12404. * Creates a new SubEmitter from a serialized JSON version
  12405. * @param serializationObject defines the JSON object to read from
  12406. * @param scene defines the hosting scene
  12407. * @param rootUrl defines the rootUrl for data loading
  12408. * @returns a new SubEmitter
  12409. */
  12410. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12411. /** Release associated resources */
  12412. dispose(): void;
  12413. }
  12414. }
  12415. declare module BABYLON {
  12416. /** @hidden */
  12417. export var imageProcessingDeclaration: {
  12418. name: string;
  12419. shader: string;
  12420. };
  12421. }
  12422. declare module BABYLON {
  12423. /** @hidden */
  12424. export var imageProcessingFunctions: {
  12425. name: string;
  12426. shader: string;
  12427. };
  12428. }
  12429. declare module BABYLON {
  12430. /** @hidden */
  12431. export var particlesPixelShader: {
  12432. name: string;
  12433. shader: string;
  12434. };
  12435. }
  12436. declare module BABYLON {
  12437. /** @hidden */
  12438. export var particlesVertexShader: {
  12439. name: string;
  12440. shader: string;
  12441. };
  12442. }
  12443. declare module BABYLON {
  12444. /**
  12445. * This represents a particle system in Babylon.
  12446. * 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.
  12447. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12448. * @example https://doc.babylonjs.com/babylon101/particles
  12449. */
  12450. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12451. /**
  12452. * Billboard mode will only apply to Y axis
  12453. */
  12454. static readonly BILLBOARDMODE_Y: number;
  12455. /**
  12456. * Billboard mode will apply to all axes
  12457. */
  12458. static readonly BILLBOARDMODE_ALL: number;
  12459. /**
  12460. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12461. */
  12462. static readonly BILLBOARDMODE_STRETCHED: number;
  12463. /**
  12464. * This function can be defined to provide custom update for active particles.
  12465. * This function will be called instead of regular update (age, position, color, etc.).
  12466. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12467. */
  12468. updateFunction: (particles: Particle[]) => void;
  12469. private _emitterWorldMatrix;
  12470. /**
  12471. * This function can be defined to specify initial direction for every new particle.
  12472. * It by default use the emitterType defined function
  12473. */
  12474. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12475. /**
  12476. * This function can be defined to specify initial position for every new particle.
  12477. * It by default use the emitterType defined function
  12478. */
  12479. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12480. /**
  12481. * @hidden
  12482. */
  12483. _inheritedVelocityOffset: Vector3;
  12484. /**
  12485. * An event triggered when the system is disposed
  12486. */
  12487. onDisposeObservable: Observable<IParticleSystem>;
  12488. private _onDisposeObserver;
  12489. /**
  12490. * Sets a callback that will be triggered when the system is disposed
  12491. */
  12492. set onDispose(callback: () => void);
  12493. private _particles;
  12494. private _epsilon;
  12495. private _capacity;
  12496. private _stockParticles;
  12497. private _newPartsExcess;
  12498. private _vertexData;
  12499. private _vertexBuffer;
  12500. private _vertexBuffers;
  12501. private _spriteBuffer;
  12502. private _indexBuffer;
  12503. private _effect;
  12504. private _customEffect;
  12505. private _cachedDefines;
  12506. private _scaledColorStep;
  12507. private _colorDiff;
  12508. private _scaledDirection;
  12509. private _scaledGravity;
  12510. private _currentRenderId;
  12511. private _alive;
  12512. private _useInstancing;
  12513. private _started;
  12514. private _stopped;
  12515. private _actualFrame;
  12516. private _scaledUpdateSpeed;
  12517. private _vertexBufferSize;
  12518. /** @hidden */
  12519. _currentEmitRateGradient: Nullable<FactorGradient>;
  12520. /** @hidden */
  12521. _currentEmitRate1: number;
  12522. /** @hidden */
  12523. _currentEmitRate2: number;
  12524. /** @hidden */
  12525. _currentStartSizeGradient: Nullable<FactorGradient>;
  12526. /** @hidden */
  12527. _currentStartSize1: number;
  12528. /** @hidden */
  12529. _currentStartSize2: number;
  12530. private readonly _rawTextureWidth;
  12531. private _rampGradientsTexture;
  12532. private _useRampGradients;
  12533. /** Gets or sets a boolean indicating that ramp gradients must be used
  12534. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12535. */
  12536. get useRampGradients(): boolean;
  12537. set useRampGradients(value: boolean);
  12538. /**
  12539. * 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.
  12540. * 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: [])
  12541. */
  12542. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12543. private _subEmitters;
  12544. /**
  12545. * @hidden
  12546. * If the particle systems emitter should be disposed when the particle system is disposed
  12547. */
  12548. _disposeEmitterOnDispose: boolean;
  12549. /**
  12550. * The current active Sub-systems, this property is used by the root particle system only.
  12551. */
  12552. activeSubSystems: Array<ParticleSystem>;
  12553. /**
  12554. * Specifies if the particles are updated in emitter local space or world space
  12555. */
  12556. isLocal: boolean;
  12557. private _rootParticleSystem;
  12558. /**
  12559. * Gets the current list of active particles
  12560. */
  12561. get particles(): Particle[];
  12562. /**
  12563. * Gets the number of particles active at the same time.
  12564. * @returns The number of active particles.
  12565. */
  12566. getActiveCount(): number;
  12567. /**
  12568. * Returns the string "ParticleSystem"
  12569. * @returns a string containing the class name
  12570. */
  12571. getClassName(): string;
  12572. /**
  12573. * Gets a boolean indicating that the system is stopping
  12574. * @returns true if the system is currently stopping
  12575. */
  12576. isStopping(): boolean;
  12577. /**
  12578. * Gets the custom effect used to render the particles
  12579. * @param blendMode Blend mode for which the effect should be retrieved
  12580. * @returns The effect
  12581. */
  12582. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12583. /**
  12584. * Sets the custom effect used to render the particles
  12585. * @param effect The effect to set
  12586. * @param blendMode Blend mode for which the effect should be set
  12587. */
  12588. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12589. /** @hidden */
  12590. private _onBeforeDrawParticlesObservable;
  12591. /**
  12592. * Observable that will be called just before the particles are drawn
  12593. */
  12594. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12595. /**
  12596. * Gets the name of the particle vertex shader
  12597. */
  12598. get vertexShaderName(): string;
  12599. /**
  12600. * Instantiates a particle system.
  12601. * 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.
  12602. * @param name The name of the particle system
  12603. * @param capacity The max number of particles alive at the same time
  12604. * @param scene The scene the particle system belongs to
  12605. * @param customEffect a custom effect used to change the way particles are rendered by default
  12606. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12607. * @param epsilon Offset used to render the particles
  12608. */
  12609. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12610. private _addFactorGradient;
  12611. private _removeFactorGradient;
  12612. /**
  12613. * Adds a new life time gradient
  12614. * @param gradient defines the gradient to use (between 0 and 1)
  12615. * @param factor defines the life time factor to affect to the specified gradient
  12616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12617. * @returns the current particle system
  12618. */
  12619. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12620. /**
  12621. * Remove a specific life time gradient
  12622. * @param gradient defines the gradient to remove
  12623. * @returns the current particle system
  12624. */
  12625. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12626. /**
  12627. * Adds a new size gradient
  12628. * @param gradient defines the gradient to use (between 0 and 1)
  12629. * @param factor defines the size factor to affect to the specified gradient
  12630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12631. * @returns the current particle system
  12632. */
  12633. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12634. /**
  12635. * Remove a specific size gradient
  12636. * @param gradient defines the gradient to remove
  12637. * @returns the current particle system
  12638. */
  12639. removeSizeGradient(gradient: number): IParticleSystem;
  12640. /**
  12641. * Adds a new color remap gradient
  12642. * @param gradient defines the gradient to use (between 0 and 1)
  12643. * @param min defines the color remap minimal range
  12644. * @param max defines the color remap maximal range
  12645. * @returns the current particle system
  12646. */
  12647. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12648. /**
  12649. * Remove a specific color remap gradient
  12650. * @param gradient defines the gradient to remove
  12651. * @returns the current particle system
  12652. */
  12653. removeColorRemapGradient(gradient: number): IParticleSystem;
  12654. /**
  12655. * Adds a new alpha remap gradient
  12656. * @param gradient defines the gradient to use (between 0 and 1)
  12657. * @param min defines the alpha remap minimal range
  12658. * @param max defines the alpha remap maximal range
  12659. * @returns the current particle system
  12660. */
  12661. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12662. /**
  12663. * Remove a specific alpha remap gradient
  12664. * @param gradient defines the gradient to remove
  12665. * @returns the current particle system
  12666. */
  12667. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12668. /**
  12669. * Adds a new angular speed gradient
  12670. * @param gradient defines the gradient to use (between 0 and 1)
  12671. * @param factor defines the angular speed to affect to the specified gradient
  12672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12673. * @returns the current particle system
  12674. */
  12675. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12676. /**
  12677. * Remove a specific angular speed gradient
  12678. * @param gradient defines the gradient to remove
  12679. * @returns the current particle system
  12680. */
  12681. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12682. /**
  12683. * Adds a new velocity gradient
  12684. * @param gradient defines the gradient to use (between 0 and 1)
  12685. * @param factor defines the velocity to affect to the specified gradient
  12686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12687. * @returns the current particle system
  12688. */
  12689. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12690. /**
  12691. * Remove a specific velocity gradient
  12692. * @param gradient defines the gradient to remove
  12693. * @returns the current particle system
  12694. */
  12695. removeVelocityGradient(gradient: number): IParticleSystem;
  12696. /**
  12697. * Adds a new limit velocity gradient
  12698. * @param gradient defines the gradient to use (between 0 and 1)
  12699. * @param factor defines the limit velocity value to affect to the specified gradient
  12700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12701. * @returns the current particle system
  12702. */
  12703. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12704. /**
  12705. * Remove a specific limit velocity gradient
  12706. * @param gradient defines the gradient to remove
  12707. * @returns the current particle system
  12708. */
  12709. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12710. /**
  12711. * Adds a new drag gradient
  12712. * @param gradient defines the gradient to use (between 0 and 1)
  12713. * @param factor defines the drag value to affect to the specified gradient
  12714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12715. * @returns the current particle system
  12716. */
  12717. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12718. /**
  12719. * Remove a specific drag gradient
  12720. * @param gradient defines the gradient to remove
  12721. * @returns the current particle system
  12722. */
  12723. removeDragGradient(gradient: number): IParticleSystem;
  12724. /**
  12725. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12726. * @param gradient defines the gradient to use (between 0 and 1)
  12727. * @param factor defines the emit rate value to affect to the specified gradient
  12728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12729. * @returns the current particle system
  12730. */
  12731. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12732. /**
  12733. * Remove a specific emit rate gradient
  12734. * @param gradient defines the gradient to remove
  12735. * @returns the current particle system
  12736. */
  12737. removeEmitRateGradient(gradient: number): IParticleSystem;
  12738. /**
  12739. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12740. * @param gradient defines the gradient to use (between 0 and 1)
  12741. * @param factor defines the start size value to affect to the specified gradient
  12742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12743. * @returns the current particle system
  12744. */
  12745. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12746. /**
  12747. * Remove a specific start size gradient
  12748. * @param gradient defines the gradient to remove
  12749. * @returns the current particle system
  12750. */
  12751. removeStartSizeGradient(gradient: number): IParticleSystem;
  12752. private _createRampGradientTexture;
  12753. /**
  12754. * Gets the current list of ramp gradients.
  12755. * You must use addRampGradient and removeRampGradient to udpate this list
  12756. * @returns the list of ramp gradients
  12757. */
  12758. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12759. /** Force the system to rebuild all gradients that need to be resync */
  12760. forceRefreshGradients(): void;
  12761. private _syncRampGradientTexture;
  12762. /**
  12763. * Adds a new ramp gradient used to remap particle colors
  12764. * @param gradient defines the gradient to use (between 0 and 1)
  12765. * @param color defines the color to affect to the specified gradient
  12766. * @returns the current particle system
  12767. */
  12768. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12769. /**
  12770. * Remove a specific ramp gradient
  12771. * @param gradient defines the gradient to remove
  12772. * @returns the current particle system
  12773. */
  12774. removeRampGradient(gradient: number): ParticleSystem;
  12775. /**
  12776. * Adds a new color gradient
  12777. * @param gradient defines the gradient to use (between 0 and 1)
  12778. * @param color1 defines the color to affect to the specified gradient
  12779. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12780. * @returns this particle system
  12781. */
  12782. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12783. /**
  12784. * Remove a specific color gradient
  12785. * @param gradient defines the gradient to remove
  12786. * @returns this particle system
  12787. */
  12788. removeColorGradient(gradient: number): IParticleSystem;
  12789. private _fetchR;
  12790. protected _reset(): void;
  12791. private _resetEffect;
  12792. private _createVertexBuffers;
  12793. private _createIndexBuffer;
  12794. /**
  12795. * Gets the maximum number of particles active at the same time.
  12796. * @returns The max number of active particles.
  12797. */
  12798. getCapacity(): number;
  12799. /**
  12800. * Gets whether there are still active particles in the system.
  12801. * @returns True if it is alive, otherwise false.
  12802. */
  12803. isAlive(): boolean;
  12804. /**
  12805. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12806. * @returns True if it has been started, otherwise false.
  12807. */
  12808. isStarted(): boolean;
  12809. private _prepareSubEmitterInternalArray;
  12810. /**
  12811. * Starts the particle system and begins to emit
  12812. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12813. */
  12814. start(delay?: number): void;
  12815. /**
  12816. * Stops the particle system.
  12817. * @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.
  12818. */
  12819. stop(stopSubEmitters?: boolean): void;
  12820. /**
  12821. * Remove all active particles
  12822. */
  12823. reset(): void;
  12824. /**
  12825. * @hidden (for internal use only)
  12826. */
  12827. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12828. /**
  12829. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12830. * Its lifetime will start back at 0.
  12831. */
  12832. recycleParticle: (particle: Particle) => void;
  12833. private _stopSubEmitters;
  12834. private _createParticle;
  12835. private _removeFromRoot;
  12836. private _emitFromParticle;
  12837. private _update;
  12838. /** @hidden */
  12839. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12840. /** @hidden */
  12841. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12842. /**
  12843. * Fill the defines array according to the current settings of the particle system
  12844. * @param defines Array to be updated
  12845. * @param blendMode blend mode to take into account when updating the array
  12846. */
  12847. fillDefines(defines: Array<string>, blendMode: number): void;
  12848. /**
  12849. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12850. * @param uniforms Uniforms array to fill
  12851. * @param attributes Attributes array to fill
  12852. * @param samplers Samplers array to fill
  12853. */
  12854. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12855. /** @hidden */
  12856. private _getEffect;
  12857. /**
  12858. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12859. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12860. */
  12861. animate(preWarmOnly?: boolean): void;
  12862. private _appendParticleVertices;
  12863. /**
  12864. * Rebuilds the particle system.
  12865. */
  12866. rebuild(): void;
  12867. /**
  12868. * Is this system ready to be used/rendered
  12869. * @return true if the system is ready
  12870. */
  12871. isReady(): boolean;
  12872. private _render;
  12873. /**
  12874. * Renders the particle system in its current state.
  12875. * @returns the current number of particles
  12876. */
  12877. render(): number;
  12878. /**
  12879. * Disposes the particle system and free the associated resources
  12880. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12881. */
  12882. dispose(disposeTexture?: boolean): void;
  12883. /**
  12884. * Clones the particle system.
  12885. * @param name The name of the cloned object
  12886. * @param newEmitter The new emitter to use
  12887. * @returns the cloned particle system
  12888. */
  12889. clone(name: string, newEmitter: any): ParticleSystem;
  12890. /**
  12891. * Serializes the particle system to a JSON object
  12892. * @param serializeTexture defines if the texture must be serialized as well
  12893. * @returns the JSON object
  12894. */
  12895. serialize(serializeTexture?: boolean): any;
  12896. /** @hidden */
  12897. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12898. /** @hidden */
  12899. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12900. /**
  12901. * Parses a JSON object to create a particle system.
  12902. * @param parsedParticleSystem The JSON object to parse
  12903. * @param scene The scene to create the particle system in
  12904. * @param rootUrl The root url to use to load external dependencies like texture
  12905. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12906. * @returns the Parsed particle system
  12907. */
  12908. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12909. }
  12910. }
  12911. declare module BABYLON {
  12912. /**
  12913. * A particle represents one of the element emitted by a particle system.
  12914. * This is mainly define by its coordinates, direction, velocity and age.
  12915. */
  12916. export class Particle {
  12917. /**
  12918. * The particle system the particle belongs to.
  12919. */
  12920. particleSystem: ParticleSystem;
  12921. private static _Count;
  12922. /**
  12923. * Unique ID of the particle
  12924. */
  12925. id: number;
  12926. /**
  12927. * The world position of the particle in the scene.
  12928. */
  12929. position: Vector3;
  12930. /**
  12931. * The world direction of the particle in the scene.
  12932. */
  12933. direction: Vector3;
  12934. /**
  12935. * The color of the particle.
  12936. */
  12937. color: Color4;
  12938. /**
  12939. * The color change of the particle per step.
  12940. */
  12941. colorStep: Color4;
  12942. /**
  12943. * Defines how long will the life of the particle be.
  12944. */
  12945. lifeTime: number;
  12946. /**
  12947. * The current age of the particle.
  12948. */
  12949. age: number;
  12950. /**
  12951. * The current size of the particle.
  12952. */
  12953. size: number;
  12954. /**
  12955. * The current scale of the particle.
  12956. */
  12957. scale: Vector2;
  12958. /**
  12959. * The current angle of the particle.
  12960. */
  12961. angle: number;
  12962. /**
  12963. * Defines how fast is the angle changing.
  12964. */
  12965. angularSpeed: number;
  12966. /**
  12967. * Defines the cell index used by the particle to be rendered from a sprite.
  12968. */
  12969. cellIndex: number;
  12970. /**
  12971. * The information required to support color remapping
  12972. */
  12973. remapData: Vector4;
  12974. /** @hidden */
  12975. _randomCellOffset?: number;
  12976. /** @hidden */
  12977. _initialDirection: Nullable<Vector3>;
  12978. /** @hidden */
  12979. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12980. /** @hidden */
  12981. _initialStartSpriteCellID: number;
  12982. /** @hidden */
  12983. _initialEndSpriteCellID: number;
  12984. /** @hidden */
  12985. _currentColorGradient: Nullable<ColorGradient>;
  12986. /** @hidden */
  12987. _currentColor1: Color4;
  12988. /** @hidden */
  12989. _currentColor2: Color4;
  12990. /** @hidden */
  12991. _currentSizeGradient: Nullable<FactorGradient>;
  12992. /** @hidden */
  12993. _currentSize1: number;
  12994. /** @hidden */
  12995. _currentSize2: number;
  12996. /** @hidden */
  12997. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12998. /** @hidden */
  12999. _currentAngularSpeed1: number;
  13000. /** @hidden */
  13001. _currentAngularSpeed2: number;
  13002. /** @hidden */
  13003. _currentVelocityGradient: Nullable<FactorGradient>;
  13004. /** @hidden */
  13005. _currentVelocity1: number;
  13006. /** @hidden */
  13007. _currentVelocity2: number;
  13008. /** @hidden */
  13009. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13010. /** @hidden */
  13011. _currentLimitVelocity1: number;
  13012. /** @hidden */
  13013. _currentLimitVelocity2: number;
  13014. /** @hidden */
  13015. _currentDragGradient: Nullable<FactorGradient>;
  13016. /** @hidden */
  13017. _currentDrag1: number;
  13018. /** @hidden */
  13019. _currentDrag2: number;
  13020. /** @hidden */
  13021. _randomNoiseCoordinates1: Vector3;
  13022. /** @hidden */
  13023. _randomNoiseCoordinates2: Vector3;
  13024. /** @hidden */
  13025. _localPosition?: Vector3;
  13026. /**
  13027. * Creates a new instance Particle
  13028. * @param particleSystem the particle system the particle belongs to
  13029. */
  13030. constructor(
  13031. /**
  13032. * The particle system the particle belongs to.
  13033. */
  13034. particleSystem: ParticleSystem);
  13035. private updateCellInfoFromSystem;
  13036. /**
  13037. * Defines how the sprite cell index is updated for the particle
  13038. */
  13039. updateCellIndex(): void;
  13040. /** @hidden */
  13041. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13042. /** @hidden */
  13043. _inheritParticleInfoToSubEmitters(): void;
  13044. /** @hidden */
  13045. _reset(): void;
  13046. /**
  13047. * Copy the properties of particle to another one.
  13048. * @param other the particle to copy the information to.
  13049. */
  13050. copyTo(other: Particle): void;
  13051. }
  13052. }
  13053. declare module BABYLON {
  13054. /**
  13055. * Particle emitter represents a volume emitting particles.
  13056. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13057. */
  13058. export interface IParticleEmitterType {
  13059. /**
  13060. * Called by the particle System when the direction is computed for the created particle.
  13061. * @param worldMatrix is the world matrix of the particle system
  13062. * @param directionToUpdate is the direction vector to update with the result
  13063. * @param particle is the particle we are computed the direction for
  13064. * @param isLocal defines if the direction should be set in local space
  13065. */
  13066. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13067. /**
  13068. * Called by the particle System when the position is computed for the created particle.
  13069. * @param worldMatrix is the world matrix of the particle system
  13070. * @param positionToUpdate is the position vector to update with the result
  13071. * @param particle is the particle we are computed the position for
  13072. * @param isLocal defines if the position should be set in local space
  13073. */
  13074. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13075. /**
  13076. * Clones the current emitter and returns a copy of it
  13077. * @returns the new emitter
  13078. */
  13079. clone(): IParticleEmitterType;
  13080. /**
  13081. * Called by the GPUParticleSystem to setup the update shader
  13082. * @param effect defines the update shader
  13083. */
  13084. applyToShader(effect: Effect): void;
  13085. /**
  13086. * Returns a string to use to update the GPU particles update shader
  13087. * @returns the effect defines string
  13088. */
  13089. getEffectDefines(): string;
  13090. /**
  13091. * Returns a string representing the class name
  13092. * @returns a string containing the class name
  13093. */
  13094. getClassName(): string;
  13095. /**
  13096. * Serializes the particle system to a JSON object.
  13097. * @returns the JSON object
  13098. */
  13099. serialize(): any;
  13100. /**
  13101. * Parse properties from a JSON object
  13102. * @param serializationObject defines the JSON object
  13103. * @param scene defines the hosting scene
  13104. */
  13105. parse(serializationObject: any, scene: Scene): void;
  13106. }
  13107. }
  13108. declare module BABYLON {
  13109. /**
  13110. * Particle emitter emitting particles from the inside of a box.
  13111. * It emits the particles randomly between 2 given directions.
  13112. */
  13113. export class BoxParticleEmitter implements IParticleEmitterType {
  13114. /**
  13115. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13116. */
  13117. direction1: Vector3;
  13118. /**
  13119. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13120. */
  13121. direction2: Vector3;
  13122. /**
  13123. * 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.
  13124. */
  13125. minEmitBox: Vector3;
  13126. /**
  13127. * 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.
  13128. */
  13129. maxEmitBox: Vector3;
  13130. /**
  13131. * Creates a new instance BoxParticleEmitter
  13132. */
  13133. constructor();
  13134. /**
  13135. * Called by the particle System when the direction is computed for the created particle.
  13136. * @param worldMatrix is the world matrix of the particle system
  13137. * @param directionToUpdate is the direction vector to update with the result
  13138. * @param particle is the particle we are computed the direction for
  13139. * @param isLocal defines if the direction should be set in local space
  13140. */
  13141. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13142. /**
  13143. * Called by the particle System when the position is computed for the created particle.
  13144. * @param worldMatrix is the world matrix of the particle system
  13145. * @param positionToUpdate is the position vector to update with the result
  13146. * @param particle is the particle we are computed the position for
  13147. * @param isLocal defines if the position should be set in local space
  13148. */
  13149. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13150. /**
  13151. * Clones the current emitter and returns a copy of it
  13152. * @returns the new emitter
  13153. */
  13154. clone(): BoxParticleEmitter;
  13155. /**
  13156. * Called by the GPUParticleSystem to setup the update shader
  13157. * @param effect defines the update shader
  13158. */
  13159. applyToShader(effect: Effect): void;
  13160. /**
  13161. * Returns a string to use to update the GPU particles update shader
  13162. * @returns a string containng the defines string
  13163. */
  13164. getEffectDefines(): string;
  13165. /**
  13166. * Returns the string "BoxParticleEmitter"
  13167. * @returns a string containing the class name
  13168. */
  13169. getClassName(): string;
  13170. /**
  13171. * Serializes the particle system to a JSON object.
  13172. * @returns the JSON object
  13173. */
  13174. serialize(): any;
  13175. /**
  13176. * Parse properties from a JSON object
  13177. * @param serializationObject defines the JSON object
  13178. */
  13179. parse(serializationObject: any): void;
  13180. }
  13181. }
  13182. declare module BABYLON {
  13183. /**
  13184. * Particle emitter emitting particles from the inside of a cone.
  13185. * It emits the particles alongside the cone volume from the base to the particle.
  13186. * The emission direction might be randomized.
  13187. */
  13188. export class ConeParticleEmitter implements IParticleEmitterType {
  13189. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13190. directionRandomizer: number;
  13191. private _radius;
  13192. private _angle;
  13193. private _height;
  13194. /**
  13195. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13196. */
  13197. radiusRange: number;
  13198. /**
  13199. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13200. */
  13201. heightRange: number;
  13202. /**
  13203. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13204. */
  13205. emitFromSpawnPointOnly: boolean;
  13206. /**
  13207. * Gets or sets the radius of the emission cone
  13208. */
  13209. get radius(): number;
  13210. set radius(value: number);
  13211. /**
  13212. * Gets or sets the angle of the emission cone
  13213. */
  13214. get angle(): number;
  13215. set angle(value: number);
  13216. private _buildHeight;
  13217. /**
  13218. * Creates a new instance ConeParticleEmitter
  13219. * @param radius the radius of the emission cone (1 by default)
  13220. * @param angle the cone base angle (PI by default)
  13221. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13222. */
  13223. constructor(radius?: number, angle?: number,
  13224. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13225. directionRandomizer?: number);
  13226. /**
  13227. * Called by the particle System when the direction is computed for the created particle.
  13228. * @param worldMatrix is the world matrix of the particle system
  13229. * @param directionToUpdate is the direction vector to update with the result
  13230. * @param particle is the particle we are computed the direction for
  13231. * @param isLocal defines if the direction should be set in local space
  13232. */
  13233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13234. /**
  13235. * Called by the particle System when the position is computed for the created particle.
  13236. * @param worldMatrix is the world matrix of the particle system
  13237. * @param positionToUpdate is the position vector to update with the result
  13238. * @param particle is the particle we are computed the position for
  13239. * @param isLocal defines if the position should be set in local space
  13240. */
  13241. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13242. /**
  13243. * Clones the current emitter and returns a copy of it
  13244. * @returns the new emitter
  13245. */
  13246. clone(): ConeParticleEmitter;
  13247. /**
  13248. * Called by the GPUParticleSystem to setup the update shader
  13249. * @param effect defines the update shader
  13250. */
  13251. applyToShader(effect: Effect): void;
  13252. /**
  13253. * Returns a string to use to update the GPU particles update shader
  13254. * @returns a string containng the defines string
  13255. */
  13256. getEffectDefines(): string;
  13257. /**
  13258. * Returns the string "ConeParticleEmitter"
  13259. * @returns a string containing the class name
  13260. */
  13261. getClassName(): string;
  13262. /**
  13263. * Serializes the particle system to a JSON object.
  13264. * @returns the JSON object
  13265. */
  13266. serialize(): any;
  13267. /**
  13268. * Parse properties from a JSON object
  13269. * @param serializationObject defines the JSON object
  13270. */
  13271. parse(serializationObject: any): void;
  13272. }
  13273. }
  13274. declare module BABYLON {
  13275. /**
  13276. * Particle emitter emitting particles from the inside of a cylinder.
  13277. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13278. */
  13279. export class CylinderParticleEmitter implements IParticleEmitterType {
  13280. /**
  13281. * The radius of the emission cylinder.
  13282. */
  13283. radius: number;
  13284. /**
  13285. * The height of the emission cylinder.
  13286. */
  13287. height: number;
  13288. /**
  13289. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13290. */
  13291. radiusRange: number;
  13292. /**
  13293. * How much to randomize the particle direction [0-1].
  13294. */
  13295. directionRandomizer: number;
  13296. /**
  13297. * Creates a new instance CylinderParticleEmitter
  13298. * @param radius the radius of the emission cylinder (1 by default)
  13299. * @param height the height of the emission cylinder (1 by default)
  13300. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13301. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13302. */
  13303. constructor(
  13304. /**
  13305. * The radius of the emission cylinder.
  13306. */
  13307. radius?: number,
  13308. /**
  13309. * The height of the emission cylinder.
  13310. */
  13311. height?: number,
  13312. /**
  13313. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13314. */
  13315. radiusRange?: number,
  13316. /**
  13317. * How much to randomize the particle direction [0-1].
  13318. */
  13319. directionRandomizer?: number);
  13320. /**
  13321. * Called by the particle System when the direction is computed for the created particle.
  13322. * @param worldMatrix is the world matrix of the particle system
  13323. * @param directionToUpdate is the direction vector to update with the result
  13324. * @param particle is the particle we are computed the direction for
  13325. * @param isLocal defines if the direction should be set in local space
  13326. */
  13327. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13328. /**
  13329. * Called by the particle System when the position is computed for the created particle.
  13330. * @param worldMatrix is the world matrix of the particle system
  13331. * @param positionToUpdate is the position vector to update with the result
  13332. * @param particle is the particle we are computed the position for
  13333. * @param isLocal defines if the position should be set in local space
  13334. */
  13335. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13336. /**
  13337. * Clones the current emitter and returns a copy of it
  13338. * @returns the new emitter
  13339. */
  13340. clone(): CylinderParticleEmitter;
  13341. /**
  13342. * Called by the GPUParticleSystem to setup the update shader
  13343. * @param effect defines the update shader
  13344. */
  13345. applyToShader(effect: Effect): void;
  13346. /**
  13347. * Returns a string to use to update the GPU particles update shader
  13348. * @returns a string containng the defines string
  13349. */
  13350. getEffectDefines(): string;
  13351. /**
  13352. * Returns the string "CylinderParticleEmitter"
  13353. * @returns a string containing the class name
  13354. */
  13355. getClassName(): string;
  13356. /**
  13357. * Serializes the particle system to a JSON object.
  13358. * @returns the JSON object
  13359. */
  13360. serialize(): any;
  13361. /**
  13362. * Parse properties from a JSON object
  13363. * @param serializationObject defines the JSON object
  13364. */
  13365. parse(serializationObject: any): void;
  13366. }
  13367. /**
  13368. * Particle emitter emitting particles from the inside of a cylinder.
  13369. * It emits the particles randomly between two vectors.
  13370. */
  13371. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13372. /**
  13373. * The min limit of the emission direction.
  13374. */
  13375. direction1: Vector3;
  13376. /**
  13377. * The max limit of the emission direction.
  13378. */
  13379. direction2: Vector3;
  13380. /**
  13381. * Creates a new instance CylinderDirectedParticleEmitter
  13382. * @param radius the radius of the emission cylinder (1 by default)
  13383. * @param height the height of the emission cylinder (1 by default)
  13384. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13385. * @param direction1 the min limit of the emission direction (up vector by default)
  13386. * @param direction2 the max limit of the emission direction (up vector by default)
  13387. */
  13388. constructor(radius?: number, height?: number, radiusRange?: number,
  13389. /**
  13390. * The min limit of the emission direction.
  13391. */
  13392. direction1?: Vector3,
  13393. /**
  13394. * The max limit of the emission direction.
  13395. */
  13396. direction2?: Vector3);
  13397. /**
  13398. * Called by the particle System when the direction is computed for the created particle.
  13399. * @param worldMatrix is the world matrix of the particle system
  13400. * @param directionToUpdate is the direction vector to update with the result
  13401. * @param particle is the particle we are computed the direction for
  13402. */
  13403. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13404. /**
  13405. * Clones the current emitter and returns a copy of it
  13406. * @returns the new emitter
  13407. */
  13408. clone(): CylinderDirectedParticleEmitter;
  13409. /**
  13410. * Called by the GPUParticleSystem to setup the update shader
  13411. * @param effect defines the update shader
  13412. */
  13413. applyToShader(effect: Effect): void;
  13414. /**
  13415. * Returns a string to use to update the GPU particles update shader
  13416. * @returns a string containng the defines string
  13417. */
  13418. getEffectDefines(): string;
  13419. /**
  13420. * Returns the string "CylinderDirectedParticleEmitter"
  13421. * @returns a string containing the class name
  13422. */
  13423. getClassName(): string;
  13424. /**
  13425. * Serializes the particle system to a JSON object.
  13426. * @returns the JSON object
  13427. */
  13428. serialize(): any;
  13429. /**
  13430. * Parse properties from a JSON object
  13431. * @param serializationObject defines the JSON object
  13432. */
  13433. parse(serializationObject: any): void;
  13434. }
  13435. }
  13436. declare module BABYLON {
  13437. /**
  13438. * Particle emitter emitting particles from the inside of a hemisphere.
  13439. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13440. */
  13441. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13442. /**
  13443. * The radius of the emission hemisphere.
  13444. */
  13445. radius: number;
  13446. /**
  13447. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13448. */
  13449. radiusRange: number;
  13450. /**
  13451. * How much to randomize the particle direction [0-1].
  13452. */
  13453. directionRandomizer: number;
  13454. /**
  13455. * Creates a new instance HemisphericParticleEmitter
  13456. * @param radius the radius of the emission hemisphere (1 by default)
  13457. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13458. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13459. */
  13460. constructor(
  13461. /**
  13462. * The radius of the emission hemisphere.
  13463. */
  13464. radius?: number,
  13465. /**
  13466. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13467. */
  13468. radiusRange?: number,
  13469. /**
  13470. * How much to randomize the particle direction [0-1].
  13471. */
  13472. directionRandomizer?: number);
  13473. /**
  13474. * Called by the particle System when the direction is computed for the created particle.
  13475. * @param worldMatrix is the world matrix of the particle system
  13476. * @param directionToUpdate is the direction vector to update with the result
  13477. * @param particle is the particle we are computed the direction for
  13478. * @param isLocal defines if the direction should be set in local space
  13479. */
  13480. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13481. /**
  13482. * Called by the particle System when the position is computed for the created particle.
  13483. * @param worldMatrix is the world matrix of the particle system
  13484. * @param positionToUpdate is the position vector to update with the result
  13485. * @param particle is the particle we are computed the position for
  13486. * @param isLocal defines if the position should be set in local space
  13487. */
  13488. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13489. /**
  13490. * Clones the current emitter and returns a copy of it
  13491. * @returns the new emitter
  13492. */
  13493. clone(): HemisphericParticleEmitter;
  13494. /**
  13495. * Called by the GPUParticleSystem to setup the update shader
  13496. * @param effect defines the update shader
  13497. */
  13498. applyToShader(effect: Effect): void;
  13499. /**
  13500. * Returns a string to use to update the GPU particles update shader
  13501. * @returns a string containng the defines string
  13502. */
  13503. getEffectDefines(): string;
  13504. /**
  13505. * Returns the string "HemisphericParticleEmitter"
  13506. * @returns a string containing the class name
  13507. */
  13508. getClassName(): string;
  13509. /**
  13510. * Serializes the particle system to a JSON object.
  13511. * @returns the JSON object
  13512. */
  13513. serialize(): any;
  13514. /**
  13515. * Parse properties from a JSON object
  13516. * @param serializationObject defines the JSON object
  13517. */
  13518. parse(serializationObject: any): void;
  13519. }
  13520. }
  13521. declare module BABYLON {
  13522. /**
  13523. * Particle emitter emitting particles from a point.
  13524. * It emits the particles randomly between 2 given directions.
  13525. */
  13526. export class PointParticleEmitter implements IParticleEmitterType {
  13527. /**
  13528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13529. */
  13530. direction1: Vector3;
  13531. /**
  13532. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13533. */
  13534. direction2: Vector3;
  13535. /**
  13536. * Creates a new instance PointParticleEmitter
  13537. */
  13538. constructor();
  13539. /**
  13540. * Called by the particle System when the direction is computed for the created particle.
  13541. * @param worldMatrix is the world matrix of the particle system
  13542. * @param directionToUpdate is the direction vector to update with the result
  13543. * @param particle is the particle we are computed the direction for
  13544. * @param isLocal defines if the direction should be set in local space
  13545. */
  13546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13547. /**
  13548. * Called by the particle System when the position is computed for the created particle.
  13549. * @param worldMatrix is the world matrix of the particle system
  13550. * @param positionToUpdate is the position vector to update with the result
  13551. * @param particle is the particle we are computed the position for
  13552. * @param isLocal defines if the position should be set in local space
  13553. */
  13554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13555. /**
  13556. * Clones the current emitter and returns a copy of it
  13557. * @returns the new emitter
  13558. */
  13559. clone(): PointParticleEmitter;
  13560. /**
  13561. * Called by the GPUParticleSystem to setup the update shader
  13562. * @param effect defines the update shader
  13563. */
  13564. applyToShader(effect: Effect): void;
  13565. /**
  13566. * Returns a string to use to update the GPU particles update shader
  13567. * @returns a string containng the defines string
  13568. */
  13569. getEffectDefines(): string;
  13570. /**
  13571. * Returns the string "PointParticleEmitter"
  13572. * @returns a string containing the class name
  13573. */
  13574. getClassName(): string;
  13575. /**
  13576. * Serializes the particle system to a JSON object.
  13577. * @returns the JSON object
  13578. */
  13579. serialize(): any;
  13580. /**
  13581. * Parse properties from a JSON object
  13582. * @param serializationObject defines the JSON object
  13583. */
  13584. parse(serializationObject: any): void;
  13585. }
  13586. }
  13587. declare module BABYLON {
  13588. /**
  13589. * Particle emitter emitting particles from the inside of a sphere.
  13590. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13591. */
  13592. export class SphereParticleEmitter implements IParticleEmitterType {
  13593. /**
  13594. * The radius of the emission sphere.
  13595. */
  13596. radius: number;
  13597. /**
  13598. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13599. */
  13600. radiusRange: number;
  13601. /**
  13602. * How much to randomize the particle direction [0-1].
  13603. */
  13604. directionRandomizer: number;
  13605. /**
  13606. * Creates a new instance SphereParticleEmitter
  13607. * @param radius the radius of the emission sphere (1 by default)
  13608. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13609. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13610. */
  13611. constructor(
  13612. /**
  13613. * The radius of the emission sphere.
  13614. */
  13615. radius?: number,
  13616. /**
  13617. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13618. */
  13619. radiusRange?: number,
  13620. /**
  13621. * How much to randomize the particle direction [0-1].
  13622. */
  13623. directionRandomizer?: number);
  13624. /**
  13625. * Called by the particle System when the direction is computed for the created particle.
  13626. * @param worldMatrix is the world matrix of the particle system
  13627. * @param directionToUpdate is the direction vector to update with the result
  13628. * @param particle is the particle we are computed the direction for
  13629. * @param isLocal defines if the direction should be set in local space
  13630. */
  13631. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13632. /**
  13633. * Called by the particle System when the position is computed for the created particle.
  13634. * @param worldMatrix is the world matrix of the particle system
  13635. * @param positionToUpdate is the position vector to update with the result
  13636. * @param particle is the particle we are computed the position for
  13637. * @param isLocal defines if the position should be set in local space
  13638. */
  13639. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13640. /**
  13641. * Clones the current emitter and returns a copy of it
  13642. * @returns the new emitter
  13643. */
  13644. clone(): SphereParticleEmitter;
  13645. /**
  13646. * Called by the GPUParticleSystem to setup the update shader
  13647. * @param effect defines the update shader
  13648. */
  13649. applyToShader(effect: Effect): void;
  13650. /**
  13651. * Returns a string to use to update the GPU particles update shader
  13652. * @returns a string containng the defines string
  13653. */
  13654. getEffectDefines(): string;
  13655. /**
  13656. * Returns the string "SphereParticleEmitter"
  13657. * @returns a string containing the class name
  13658. */
  13659. getClassName(): string;
  13660. /**
  13661. * Serializes the particle system to a JSON object.
  13662. * @returns the JSON object
  13663. */
  13664. serialize(): any;
  13665. /**
  13666. * Parse properties from a JSON object
  13667. * @param serializationObject defines the JSON object
  13668. */
  13669. parse(serializationObject: any): void;
  13670. }
  13671. /**
  13672. * Particle emitter emitting particles from the inside of a sphere.
  13673. * It emits the particles randomly between two vectors.
  13674. */
  13675. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13676. /**
  13677. * The min limit of the emission direction.
  13678. */
  13679. direction1: Vector3;
  13680. /**
  13681. * The max limit of the emission direction.
  13682. */
  13683. direction2: Vector3;
  13684. /**
  13685. * Creates a new instance SphereDirectedParticleEmitter
  13686. * @param radius the radius of the emission sphere (1 by default)
  13687. * @param direction1 the min limit of the emission direction (up vector by default)
  13688. * @param direction2 the max limit of the emission direction (up vector by default)
  13689. */
  13690. constructor(radius?: number,
  13691. /**
  13692. * The min limit of the emission direction.
  13693. */
  13694. direction1?: Vector3,
  13695. /**
  13696. * The max limit of the emission direction.
  13697. */
  13698. direction2?: Vector3);
  13699. /**
  13700. * Called by the particle System when the direction is computed for the created particle.
  13701. * @param worldMatrix is the world matrix of the particle system
  13702. * @param directionToUpdate is the direction vector to update with the result
  13703. * @param particle is the particle we are computed the direction for
  13704. */
  13705. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13706. /**
  13707. * Clones the current emitter and returns a copy of it
  13708. * @returns the new emitter
  13709. */
  13710. clone(): SphereDirectedParticleEmitter;
  13711. /**
  13712. * Called by the GPUParticleSystem to setup the update shader
  13713. * @param effect defines the update shader
  13714. */
  13715. applyToShader(effect: Effect): void;
  13716. /**
  13717. * Returns a string to use to update the GPU particles update shader
  13718. * @returns a string containng the defines string
  13719. */
  13720. getEffectDefines(): string;
  13721. /**
  13722. * Returns the string "SphereDirectedParticleEmitter"
  13723. * @returns a string containing the class name
  13724. */
  13725. getClassName(): string;
  13726. /**
  13727. * Serializes the particle system to a JSON object.
  13728. * @returns the JSON object
  13729. */
  13730. serialize(): any;
  13731. /**
  13732. * Parse properties from a JSON object
  13733. * @param serializationObject defines the JSON object
  13734. */
  13735. parse(serializationObject: any): void;
  13736. }
  13737. }
  13738. declare module BABYLON {
  13739. /**
  13740. * Particle emitter emitting particles from a custom list of positions.
  13741. */
  13742. export class CustomParticleEmitter implements IParticleEmitterType {
  13743. /**
  13744. * Gets or sets the position generator that will create the inital position of each particle.
  13745. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13746. */
  13747. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13748. /**
  13749. * Gets or sets the destination generator that will create the final destination of each particle.
  13750. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13751. */
  13752. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13753. /**
  13754. * Creates a new instance CustomParticleEmitter
  13755. */
  13756. constructor();
  13757. /**
  13758. * Called by the particle System when the direction is computed for the created particle.
  13759. * @param worldMatrix is the world matrix of the particle system
  13760. * @param directionToUpdate is the direction vector to update with the result
  13761. * @param particle is the particle we are computed the direction for
  13762. * @param isLocal defines if the direction should be set in local space
  13763. */
  13764. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13765. /**
  13766. * Called by the particle System when the position is computed for the created particle.
  13767. * @param worldMatrix is the world matrix of the particle system
  13768. * @param positionToUpdate is the position vector to update with the result
  13769. * @param particle is the particle we are computed the position for
  13770. * @param isLocal defines if the position should be set in local space
  13771. */
  13772. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13773. /**
  13774. * Clones the current emitter and returns a copy of it
  13775. * @returns the new emitter
  13776. */
  13777. clone(): CustomParticleEmitter;
  13778. /**
  13779. * Called by the GPUParticleSystem to setup the update shader
  13780. * @param effect defines the update shader
  13781. */
  13782. applyToShader(effect: Effect): void;
  13783. /**
  13784. * Returns a string to use to update the GPU particles update shader
  13785. * @returns a string containng the defines string
  13786. */
  13787. getEffectDefines(): string;
  13788. /**
  13789. * Returns the string "PointParticleEmitter"
  13790. * @returns a string containing the class name
  13791. */
  13792. getClassName(): string;
  13793. /**
  13794. * Serializes the particle system to a JSON object.
  13795. * @returns the JSON object
  13796. */
  13797. serialize(): any;
  13798. /**
  13799. * Parse properties from a JSON object
  13800. * @param serializationObject defines the JSON object
  13801. */
  13802. parse(serializationObject: any): void;
  13803. }
  13804. }
  13805. declare module BABYLON {
  13806. /**
  13807. * Particle emitter emitting particles from the inside of a box.
  13808. * It emits the particles randomly between 2 given directions.
  13809. */
  13810. export class MeshParticleEmitter implements IParticleEmitterType {
  13811. private _indices;
  13812. private _positions;
  13813. private _normals;
  13814. private _storedNormal;
  13815. private _mesh;
  13816. /**
  13817. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13818. */
  13819. direction1: Vector3;
  13820. /**
  13821. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13822. */
  13823. direction2: Vector3;
  13824. /**
  13825. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13826. */
  13827. useMeshNormalsForDirection: boolean;
  13828. /** Defines the mesh to use as source */
  13829. get mesh(): Nullable<AbstractMesh>;
  13830. set mesh(value: Nullable<AbstractMesh>);
  13831. /**
  13832. * Creates a new instance MeshParticleEmitter
  13833. * @param mesh defines the mesh to use as source
  13834. */
  13835. constructor(mesh?: Nullable<AbstractMesh>);
  13836. /**
  13837. * Called by the particle System when the direction is computed for the created particle.
  13838. * @param worldMatrix is the world matrix of the particle system
  13839. * @param directionToUpdate is the direction vector to update with the result
  13840. * @param particle is the particle we are computed the direction for
  13841. * @param isLocal defines if the direction should be set in local space
  13842. */
  13843. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13844. /**
  13845. * Called by the particle System when the position is computed for the created particle.
  13846. * @param worldMatrix is the world matrix of the particle system
  13847. * @param positionToUpdate is the position vector to update with the result
  13848. * @param particle is the particle we are computed the position for
  13849. * @param isLocal defines if the position should be set in local space
  13850. */
  13851. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13852. /**
  13853. * Clones the current emitter and returns a copy of it
  13854. * @returns the new emitter
  13855. */
  13856. clone(): MeshParticleEmitter;
  13857. /**
  13858. * Called by the GPUParticleSystem to setup the update shader
  13859. * @param effect defines the update shader
  13860. */
  13861. applyToShader(effect: Effect): void;
  13862. /**
  13863. * Returns a string to use to update the GPU particles update shader
  13864. * @returns a string containng the defines string
  13865. */
  13866. getEffectDefines(): string;
  13867. /**
  13868. * Returns the string "BoxParticleEmitter"
  13869. * @returns a string containing the class name
  13870. */
  13871. getClassName(): string;
  13872. /**
  13873. * Serializes the particle system to a JSON object.
  13874. * @returns the JSON object
  13875. */
  13876. serialize(): any;
  13877. /**
  13878. * Parse properties from a JSON object
  13879. * @param serializationObject defines the JSON object
  13880. * @param scene defines the hosting scene
  13881. */
  13882. parse(serializationObject: any, scene: Scene): void;
  13883. }
  13884. }
  13885. declare module BABYLON {
  13886. /**
  13887. * Interface representing a particle system in Babylon.js.
  13888. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13889. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13890. */
  13891. export interface IParticleSystem {
  13892. /**
  13893. * List of animations used by the particle system.
  13894. */
  13895. animations: Animation[];
  13896. /**
  13897. * The id of the Particle system.
  13898. */
  13899. id: string;
  13900. /**
  13901. * The name of the Particle system.
  13902. */
  13903. name: string;
  13904. /**
  13905. * The emitter represents the Mesh or position we are attaching the particle system to.
  13906. */
  13907. emitter: Nullable<AbstractMesh | Vector3>;
  13908. /**
  13909. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13910. */
  13911. isBillboardBased: boolean;
  13912. /**
  13913. * The rendering group used by the Particle system to chose when to render.
  13914. */
  13915. renderingGroupId: number;
  13916. /**
  13917. * The layer mask we are rendering the particles through.
  13918. */
  13919. layerMask: number;
  13920. /**
  13921. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13922. */
  13923. updateSpeed: number;
  13924. /**
  13925. * The amount of time the particle system is running (depends of the overall update speed).
  13926. */
  13927. targetStopDuration: number;
  13928. /**
  13929. * The texture used to render each particle. (this can be a spritesheet)
  13930. */
  13931. particleTexture: Nullable<Texture>;
  13932. /**
  13933. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13934. */
  13935. blendMode: number;
  13936. /**
  13937. * Minimum life time of emitting particles.
  13938. */
  13939. minLifeTime: number;
  13940. /**
  13941. * Maximum life time of emitting particles.
  13942. */
  13943. maxLifeTime: number;
  13944. /**
  13945. * Minimum Size of emitting particles.
  13946. */
  13947. minSize: number;
  13948. /**
  13949. * Maximum Size of emitting particles.
  13950. */
  13951. maxSize: number;
  13952. /**
  13953. * Minimum scale of emitting particles on X axis.
  13954. */
  13955. minScaleX: number;
  13956. /**
  13957. * Maximum scale of emitting particles on X axis.
  13958. */
  13959. maxScaleX: number;
  13960. /**
  13961. * Minimum scale of emitting particles on Y axis.
  13962. */
  13963. minScaleY: number;
  13964. /**
  13965. * Maximum scale of emitting particles on Y axis.
  13966. */
  13967. maxScaleY: number;
  13968. /**
  13969. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13970. */
  13971. color1: Color4;
  13972. /**
  13973. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13974. */
  13975. color2: Color4;
  13976. /**
  13977. * Color the particle will have at the end of its lifetime.
  13978. */
  13979. colorDead: Color4;
  13980. /**
  13981. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13982. */
  13983. emitRate: number;
  13984. /**
  13985. * You can use gravity if you want to give an orientation to your particles.
  13986. */
  13987. gravity: Vector3;
  13988. /**
  13989. * Minimum power of emitting particles.
  13990. */
  13991. minEmitPower: number;
  13992. /**
  13993. * Maximum power of emitting particles.
  13994. */
  13995. maxEmitPower: number;
  13996. /**
  13997. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13998. */
  13999. minAngularSpeed: number;
  14000. /**
  14001. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14002. */
  14003. maxAngularSpeed: number;
  14004. /**
  14005. * Gets or sets the minimal initial rotation in radians.
  14006. */
  14007. minInitialRotation: number;
  14008. /**
  14009. * Gets or sets the maximal initial rotation in radians.
  14010. */
  14011. maxInitialRotation: number;
  14012. /**
  14013. * The particle emitter type defines the emitter used by the particle system.
  14014. * It can be for example box, sphere, or cone...
  14015. */
  14016. particleEmitterType: Nullable<IParticleEmitterType>;
  14017. /**
  14018. * Defines the delay in milliseconds before starting the system (0 by default)
  14019. */
  14020. startDelay: number;
  14021. /**
  14022. * 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
  14023. */
  14024. preWarmCycles: number;
  14025. /**
  14026. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14027. */
  14028. preWarmStepOffset: number;
  14029. /**
  14030. * 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)
  14031. */
  14032. spriteCellChangeSpeed: number;
  14033. /**
  14034. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14035. */
  14036. startSpriteCellID: number;
  14037. /**
  14038. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14039. */
  14040. endSpriteCellID: number;
  14041. /**
  14042. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14043. */
  14044. spriteCellWidth: number;
  14045. /**
  14046. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14047. */
  14048. spriteCellHeight: number;
  14049. /**
  14050. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14051. */
  14052. spriteRandomStartCell: boolean;
  14053. /**
  14054. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14055. */
  14056. isAnimationSheetEnabled: boolean;
  14057. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14058. translationPivot: Vector2;
  14059. /**
  14060. * Gets or sets a texture used to add random noise to particle positions
  14061. */
  14062. noiseTexture: Nullable<BaseTexture>;
  14063. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14064. noiseStrength: Vector3;
  14065. /**
  14066. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14067. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14068. */
  14069. billboardMode: number;
  14070. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14071. limitVelocityDamping: number;
  14072. /**
  14073. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14074. */
  14075. beginAnimationOnStart: boolean;
  14076. /**
  14077. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14078. */
  14079. beginAnimationFrom: number;
  14080. /**
  14081. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14082. */
  14083. beginAnimationTo: number;
  14084. /**
  14085. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14086. */
  14087. beginAnimationLoop: boolean;
  14088. /**
  14089. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14090. */
  14091. disposeOnStop: boolean;
  14092. /**
  14093. * Specifies if the particles are updated in emitter local space or world space
  14094. */
  14095. isLocal: boolean;
  14096. /** Snippet ID if the particle system was created from the snippet server */
  14097. snippetId: string;
  14098. /**
  14099. * Gets the maximum number of particles active at the same time.
  14100. * @returns The max number of active particles.
  14101. */
  14102. getCapacity(): number;
  14103. /**
  14104. * Gets the number of particles active at the same time.
  14105. * @returns The number of active particles.
  14106. */
  14107. getActiveCount(): number;
  14108. /**
  14109. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14110. * @returns True if it has been started, otherwise false.
  14111. */
  14112. isStarted(): boolean;
  14113. /**
  14114. * Animates the particle system for this frame.
  14115. */
  14116. animate(): void;
  14117. /**
  14118. * Renders the particle system in its current state.
  14119. * @returns the current number of particles
  14120. */
  14121. render(): number;
  14122. /**
  14123. * Dispose the particle system and frees its associated resources.
  14124. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14125. */
  14126. dispose(disposeTexture?: boolean): void;
  14127. /**
  14128. * An event triggered when the system is disposed
  14129. */
  14130. onDisposeObservable: Observable<IParticleSystem>;
  14131. /**
  14132. * Clones the particle system.
  14133. * @param name The name of the cloned object
  14134. * @param newEmitter The new emitter to use
  14135. * @returns the cloned particle system
  14136. */
  14137. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14138. /**
  14139. * Serializes the particle system to a JSON object
  14140. * @param serializeTexture defines if the texture must be serialized as well
  14141. * @returns the JSON object
  14142. */
  14143. serialize(serializeTexture: boolean): any;
  14144. /**
  14145. * Rebuild the particle system
  14146. */
  14147. rebuild(): void;
  14148. /** Force the system to rebuild all gradients that need to be resync */
  14149. forceRefreshGradients(): void;
  14150. /**
  14151. * Starts the particle system and begins to emit
  14152. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14153. */
  14154. start(delay?: number): void;
  14155. /**
  14156. * Stops the particle system.
  14157. */
  14158. stop(): void;
  14159. /**
  14160. * Remove all active particles
  14161. */
  14162. reset(): void;
  14163. /**
  14164. * Gets a boolean indicating that the system is stopping
  14165. * @returns true if the system is currently stopping
  14166. */
  14167. isStopping(): boolean;
  14168. /**
  14169. * Is this system ready to be used/rendered
  14170. * @return true if the system is ready
  14171. */
  14172. isReady(): boolean;
  14173. /**
  14174. * Returns the string "ParticleSystem"
  14175. * @returns a string containing the class name
  14176. */
  14177. getClassName(): string;
  14178. /**
  14179. * Gets the custom effect used to render the particles
  14180. * @param blendMode Blend mode for which the effect should be retrieved
  14181. * @returns The effect
  14182. */
  14183. getCustomEffect(blendMode: number): Nullable<Effect>;
  14184. /**
  14185. * Sets the custom effect used to render the particles
  14186. * @param effect The effect to set
  14187. * @param blendMode Blend mode for which the effect should be set
  14188. */
  14189. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14190. /**
  14191. * Fill the defines array according to the current settings of the particle system
  14192. * @param defines Array to be updated
  14193. * @param blendMode blend mode to take into account when updating the array
  14194. */
  14195. fillDefines(defines: Array<string>, blendMode: number): void;
  14196. /**
  14197. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14198. * @param uniforms Uniforms array to fill
  14199. * @param attributes Attributes array to fill
  14200. * @param samplers Samplers array to fill
  14201. */
  14202. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14203. /**
  14204. * Observable that will be called just before the particles are drawn
  14205. */
  14206. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14207. /**
  14208. * Gets the name of the particle vertex shader
  14209. */
  14210. vertexShaderName: string;
  14211. /**
  14212. * Adds a new color gradient
  14213. * @param gradient defines the gradient to use (between 0 and 1)
  14214. * @param color1 defines the color to affect to the specified gradient
  14215. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14216. * @returns the current particle system
  14217. */
  14218. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14219. /**
  14220. * Remove a specific color gradient
  14221. * @param gradient defines the gradient to remove
  14222. * @returns the current particle system
  14223. */
  14224. removeColorGradient(gradient: number): IParticleSystem;
  14225. /**
  14226. * Adds a new size gradient
  14227. * @param gradient defines the gradient to use (between 0 and 1)
  14228. * @param factor defines the size factor to affect to the specified gradient
  14229. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14230. * @returns the current particle system
  14231. */
  14232. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14233. /**
  14234. * Remove a specific size gradient
  14235. * @param gradient defines the gradient to remove
  14236. * @returns the current particle system
  14237. */
  14238. removeSizeGradient(gradient: number): IParticleSystem;
  14239. /**
  14240. * Gets the current list of color gradients.
  14241. * You must use addColorGradient and removeColorGradient to udpate this list
  14242. * @returns the list of color gradients
  14243. */
  14244. getColorGradients(): Nullable<Array<ColorGradient>>;
  14245. /**
  14246. * Gets the current list of size gradients.
  14247. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14248. * @returns the list of size gradients
  14249. */
  14250. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14251. /**
  14252. * Gets the current list of angular speed gradients.
  14253. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14254. * @returns the list of angular speed gradients
  14255. */
  14256. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14257. /**
  14258. * Adds a new angular speed gradient
  14259. * @param gradient defines the gradient to use (between 0 and 1)
  14260. * @param factor defines the angular speed to affect to the specified gradient
  14261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14262. * @returns the current particle system
  14263. */
  14264. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14265. /**
  14266. * Remove a specific angular speed gradient
  14267. * @param gradient defines the gradient to remove
  14268. * @returns the current particle system
  14269. */
  14270. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14271. /**
  14272. * Gets the current list of velocity gradients.
  14273. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14274. * @returns the list of velocity gradients
  14275. */
  14276. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14277. /**
  14278. * Adds a new velocity gradient
  14279. * @param gradient defines the gradient to use (between 0 and 1)
  14280. * @param factor defines the velocity to affect to the specified gradient
  14281. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14282. * @returns the current particle system
  14283. */
  14284. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14285. /**
  14286. * Remove a specific velocity gradient
  14287. * @param gradient defines the gradient to remove
  14288. * @returns the current particle system
  14289. */
  14290. removeVelocityGradient(gradient: number): IParticleSystem;
  14291. /**
  14292. * Gets the current list of limit velocity gradients.
  14293. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14294. * @returns the list of limit velocity gradients
  14295. */
  14296. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14297. /**
  14298. * Adds a new limit velocity gradient
  14299. * @param gradient defines the gradient to use (between 0 and 1)
  14300. * @param factor defines the limit velocity to affect to the specified gradient
  14301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14302. * @returns the current particle system
  14303. */
  14304. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14305. /**
  14306. * Remove a specific limit velocity gradient
  14307. * @param gradient defines the gradient to remove
  14308. * @returns the current particle system
  14309. */
  14310. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14311. /**
  14312. * Adds a new drag gradient
  14313. * @param gradient defines the gradient to use (between 0 and 1)
  14314. * @param factor defines the drag to affect to the specified gradient
  14315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14316. * @returns the current particle system
  14317. */
  14318. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14319. /**
  14320. * Remove a specific drag gradient
  14321. * @param gradient defines the gradient to remove
  14322. * @returns the current particle system
  14323. */
  14324. removeDragGradient(gradient: number): IParticleSystem;
  14325. /**
  14326. * Gets the current list of drag gradients.
  14327. * You must use addDragGradient and removeDragGradient to udpate this list
  14328. * @returns the list of drag gradients
  14329. */
  14330. getDragGradients(): Nullable<Array<FactorGradient>>;
  14331. /**
  14332. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14333. * @param gradient defines the gradient to use (between 0 and 1)
  14334. * @param factor defines the emit rate to affect to the specified gradient
  14335. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14336. * @returns the current particle system
  14337. */
  14338. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14339. /**
  14340. * Remove a specific emit rate gradient
  14341. * @param gradient defines the gradient to remove
  14342. * @returns the current particle system
  14343. */
  14344. removeEmitRateGradient(gradient: number): IParticleSystem;
  14345. /**
  14346. * Gets the current list of emit rate gradients.
  14347. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14348. * @returns the list of emit rate gradients
  14349. */
  14350. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14351. /**
  14352. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14353. * @param gradient defines the gradient to use (between 0 and 1)
  14354. * @param factor defines the start size to affect to the specified gradient
  14355. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14356. * @returns the current particle system
  14357. */
  14358. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14359. /**
  14360. * Remove a specific start size gradient
  14361. * @param gradient defines the gradient to remove
  14362. * @returns the current particle system
  14363. */
  14364. removeStartSizeGradient(gradient: number): IParticleSystem;
  14365. /**
  14366. * Gets the current list of start size gradients.
  14367. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14368. * @returns the list of start size gradients
  14369. */
  14370. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14371. /**
  14372. * Adds a new life time gradient
  14373. * @param gradient defines the gradient to use (between 0 and 1)
  14374. * @param factor defines the life time factor to affect to the specified gradient
  14375. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14376. * @returns the current particle system
  14377. */
  14378. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14379. /**
  14380. * Remove a specific life time gradient
  14381. * @param gradient defines the gradient to remove
  14382. * @returns the current particle system
  14383. */
  14384. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14385. /**
  14386. * Gets the current list of life time gradients.
  14387. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14388. * @returns the list of life time gradients
  14389. */
  14390. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14391. /**
  14392. * Gets the current list of color gradients.
  14393. * You must use addColorGradient and removeColorGradient to udpate this list
  14394. * @returns the list of color gradients
  14395. */
  14396. getColorGradients(): Nullable<Array<ColorGradient>>;
  14397. /**
  14398. * Adds a new ramp gradient used to remap particle colors
  14399. * @param gradient defines the gradient to use (between 0 and 1)
  14400. * @param color defines the color to affect to the specified gradient
  14401. * @returns the current particle system
  14402. */
  14403. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14404. /**
  14405. * Gets the current list of ramp gradients.
  14406. * You must use addRampGradient and removeRampGradient to udpate this list
  14407. * @returns the list of ramp gradients
  14408. */
  14409. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14410. /** Gets or sets a boolean indicating that ramp gradients must be used
  14411. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14412. */
  14413. useRampGradients: boolean;
  14414. /**
  14415. * Adds a new color remap gradient
  14416. * @param gradient defines the gradient to use (between 0 and 1)
  14417. * @param min defines the color remap minimal range
  14418. * @param max defines the color remap maximal range
  14419. * @returns the current particle system
  14420. */
  14421. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14422. /**
  14423. * Gets the current list of color remap gradients.
  14424. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14425. * @returns the list of color remap gradients
  14426. */
  14427. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14428. /**
  14429. * Adds a new alpha remap gradient
  14430. * @param gradient defines the gradient to use (between 0 and 1)
  14431. * @param min defines the alpha remap minimal range
  14432. * @param max defines the alpha remap maximal range
  14433. * @returns the current particle system
  14434. */
  14435. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14436. /**
  14437. * Gets the current list of alpha remap gradients.
  14438. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14439. * @returns the list of alpha remap gradients
  14440. */
  14441. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14442. /**
  14443. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14444. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14445. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14446. * @returns the emitter
  14447. */
  14448. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14449. /**
  14450. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14451. * @param radius The radius of the hemisphere to emit from
  14452. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14453. * @returns the emitter
  14454. */
  14455. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14456. /**
  14457. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14458. * @param radius The radius of the sphere to emit from
  14459. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14460. * @returns the emitter
  14461. */
  14462. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14463. /**
  14464. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14465. * @param radius The radius of the sphere to emit from
  14466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14468. * @returns the emitter
  14469. */
  14470. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14471. /**
  14472. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14473. * @param radius The radius of the emission cylinder
  14474. * @param height The height of the emission cylinder
  14475. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14476. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14477. * @returns the emitter
  14478. */
  14479. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14480. /**
  14481. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14482. * @param radius The radius of the cylinder to emit from
  14483. * @param height The height of the emission cylinder
  14484. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14487. * @returns the emitter
  14488. */
  14489. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14490. /**
  14491. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14492. * @param radius The radius of the cone to emit from
  14493. * @param angle The base angle of the cone
  14494. * @returns the emitter
  14495. */
  14496. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14497. /**
  14498. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14499. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14500. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14501. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14502. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14503. * @returns the emitter
  14504. */
  14505. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14506. /**
  14507. * Get hosting scene
  14508. * @returns the scene
  14509. */
  14510. getScene(): Scene;
  14511. }
  14512. }
  14513. declare module BABYLON {
  14514. /**
  14515. * 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.
  14516. * @see https://doc.babylonjs.com/how_to/transformnode
  14517. */
  14518. export class TransformNode extends Node {
  14519. /**
  14520. * Object will not rotate to face the camera
  14521. */
  14522. static BILLBOARDMODE_NONE: number;
  14523. /**
  14524. * Object will rotate to face the camera but only on the x axis
  14525. */
  14526. static BILLBOARDMODE_X: number;
  14527. /**
  14528. * Object will rotate to face the camera but only on the y axis
  14529. */
  14530. static BILLBOARDMODE_Y: number;
  14531. /**
  14532. * Object will rotate to face the camera but only on the z axis
  14533. */
  14534. static BILLBOARDMODE_Z: number;
  14535. /**
  14536. * Object will rotate to face the camera
  14537. */
  14538. static BILLBOARDMODE_ALL: number;
  14539. /**
  14540. * Object will rotate to face the camera's position instead of orientation
  14541. */
  14542. static BILLBOARDMODE_USE_POSITION: number;
  14543. private _forward;
  14544. private _forwardInverted;
  14545. private _up;
  14546. private _right;
  14547. private _rightInverted;
  14548. private _position;
  14549. private _rotation;
  14550. private _rotationQuaternion;
  14551. protected _scaling: Vector3;
  14552. protected _isDirty: boolean;
  14553. private _transformToBoneReferal;
  14554. private _isAbsoluteSynced;
  14555. private _billboardMode;
  14556. /**
  14557. * Gets or sets the billboard mode. Default is 0.
  14558. *
  14559. * | Value | Type | Description |
  14560. * | --- | --- | --- |
  14561. * | 0 | BILLBOARDMODE_NONE | |
  14562. * | 1 | BILLBOARDMODE_X | |
  14563. * | 2 | BILLBOARDMODE_Y | |
  14564. * | 4 | BILLBOARDMODE_Z | |
  14565. * | 7 | BILLBOARDMODE_ALL | |
  14566. *
  14567. */
  14568. get billboardMode(): number;
  14569. set billboardMode(value: number);
  14570. private _preserveParentRotationForBillboard;
  14571. /**
  14572. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14573. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14574. */
  14575. get preserveParentRotationForBillboard(): boolean;
  14576. set preserveParentRotationForBillboard(value: boolean);
  14577. /**
  14578. * 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
  14579. */
  14580. scalingDeterminant: number;
  14581. private _infiniteDistance;
  14582. /**
  14583. * Gets or sets the distance of the object to max, often used by skybox
  14584. */
  14585. get infiniteDistance(): boolean;
  14586. set infiniteDistance(value: boolean);
  14587. /**
  14588. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14589. * By default the system will update normals to compensate
  14590. */
  14591. ignoreNonUniformScaling: boolean;
  14592. /**
  14593. * 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
  14594. */
  14595. reIntegrateRotationIntoRotationQuaternion: boolean;
  14596. /** @hidden */
  14597. _poseMatrix: Nullable<Matrix>;
  14598. /** @hidden */
  14599. _localMatrix: Matrix;
  14600. private _usePivotMatrix;
  14601. private _absolutePosition;
  14602. private _absoluteScaling;
  14603. private _absoluteRotationQuaternion;
  14604. private _pivotMatrix;
  14605. private _pivotMatrixInverse;
  14606. protected _postMultiplyPivotMatrix: boolean;
  14607. protected _isWorldMatrixFrozen: boolean;
  14608. /** @hidden */
  14609. _indexInSceneTransformNodesArray: number;
  14610. /**
  14611. * An event triggered after the world matrix is updated
  14612. */
  14613. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14614. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14615. /**
  14616. * Gets a string identifying the name of the class
  14617. * @returns "TransformNode" string
  14618. */
  14619. getClassName(): string;
  14620. /**
  14621. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14622. */
  14623. get position(): Vector3;
  14624. set position(newPosition: Vector3);
  14625. /**
  14626. * 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)).
  14627. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14628. */
  14629. get rotation(): Vector3;
  14630. set rotation(newRotation: Vector3);
  14631. /**
  14632. * 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)).
  14633. */
  14634. get scaling(): Vector3;
  14635. set scaling(newScaling: Vector3);
  14636. /**
  14637. * 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).
  14638. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14639. */
  14640. get rotationQuaternion(): Nullable<Quaternion>;
  14641. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14642. /**
  14643. * The forward direction of that transform in world space.
  14644. */
  14645. get forward(): Vector3;
  14646. /**
  14647. * The up direction of that transform in world space.
  14648. */
  14649. get up(): Vector3;
  14650. /**
  14651. * The right direction of that transform in world space.
  14652. */
  14653. get right(): Vector3;
  14654. /**
  14655. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14656. * @param matrix the matrix to copy the pose from
  14657. * @returns this TransformNode.
  14658. */
  14659. updatePoseMatrix(matrix: Matrix): TransformNode;
  14660. /**
  14661. * Returns the mesh Pose matrix.
  14662. * @returns the pose matrix
  14663. */
  14664. getPoseMatrix(): Matrix;
  14665. /** @hidden */
  14666. _isSynchronized(): boolean;
  14667. /** @hidden */
  14668. _initCache(): void;
  14669. /**
  14670. * Flag the transform node as dirty (Forcing it to update everything)
  14671. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14672. * @returns this transform node
  14673. */
  14674. markAsDirty(property: string): TransformNode;
  14675. /**
  14676. * Returns the current mesh absolute position.
  14677. * Returns a Vector3.
  14678. */
  14679. get absolutePosition(): Vector3;
  14680. /**
  14681. * Returns the current mesh absolute scaling.
  14682. * Returns a Vector3.
  14683. */
  14684. get absoluteScaling(): Vector3;
  14685. /**
  14686. * Returns the current mesh absolute rotation.
  14687. * Returns a Quaternion.
  14688. */
  14689. get absoluteRotationQuaternion(): Quaternion;
  14690. /**
  14691. * Sets a new matrix to apply before all other transformation
  14692. * @param matrix defines the transform matrix
  14693. * @returns the current TransformNode
  14694. */
  14695. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14696. /**
  14697. * Sets a new pivot matrix to the current node
  14698. * @param matrix defines the new pivot matrix to use
  14699. * @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
  14700. * @returns the current TransformNode
  14701. */
  14702. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14703. /**
  14704. * Returns the mesh pivot matrix.
  14705. * Default : Identity.
  14706. * @returns the matrix
  14707. */
  14708. getPivotMatrix(): Matrix;
  14709. /**
  14710. * Instantiate (when possible) or clone that node with its hierarchy
  14711. * @param newParent defines the new parent to use for the instance (or clone)
  14712. * @param options defines options to configure how copy is done
  14713. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14714. * @returns an instance (or a clone) of the current node with its hiearchy
  14715. */
  14716. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14717. doNotInstantiate: boolean;
  14718. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14719. /**
  14720. * Prevents the World matrix to be computed any longer
  14721. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14722. * @returns the TransformNode.
  14723. */
  14724. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14725. /**
  14726. * Allows back the World matrix computation.
  14727. * @returns the TransformNode.
  14728. */
  14729. unfreezeWorldMatrix(): this;
  14730. /**
  14731. * True if the World matrix has been frozen.
  14732. */
  14733. get isWorldMatrixFrozen(): boolean;
  14734. /**
  14735. * Retuns the mesh absolute position in the World.
  14736. * @returns a Vector3.
  14737. */
  14738. getAbsolutePosition(): Vector3;
  14739. /**
  14740. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14741. * @param absolutePosition the absolute position to set
  14742. * @returns the TransformNode.
  14743. */
  14744. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14745. /**
  14746. * Sets the mesh position in its local space.
  14747. * @param vector3 the position to set in localspace
  14748. * @returns the TransformNode.
  14749. */
  14750. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14751. /**
  14752. * Returns the mesh position in the local space from the current World matrix values.
  14753. * @returns a new Vector3.
  14754. */
  14755. getPositionExpressedInLocalSpace(): Vector3;
  14756. /**
  14757. * Translates the mesh along the passed Vector3 in its local space.
  14758. * @param vector3 the distance to translate in localspace
  14759. * @returns the TransformNode.
  14760. */
  14761. locallyTranslate(vector3: Vector3): TransformNode;
  14762. private static _lookAtVectorCache;
  14763. /**
  14764. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14765. * @param targetPoint the position (must be in same space as current mesh) to look at
  14766. * @param yawCor optional yaw (y-axis) correction in radians
  14767. * @param pitchCor optional pitch (x-axis) correction in radians
  14768. * @param rollCor optional roll (z-axis) correction in radians
  14769. * @param space the choosen space of the target
  14770. * @returns the TransformNode.
  14771. */
  14772. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14773. /**
  14774. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14775. * This Vector3 is expressed in the World space.
  14776. * @param localAxis axis to rotate
  14777. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14778. */
  14779. getDirection(localAxis: Vector3): Vector3;
  14780. /**
  14781. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14782. * localAxis is expressed in the mesh local space.
  14783. * result is computed in the Wordl space from the mesh World matrix.
  14784. * @param localAxis axis to rotate
  14785. * @param result the resulting transformnode
  14786. * @returns this TransformNode.
  14787. */
  14788. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14789. /**
  14790. * Sets this transform node rotation to the given local axis.
  14791. * @param localAxis the axis in local space
  14792. * @param yawCor optional yaw (y-axis) correction in radians
  14793. * @param pitchCor optional pitch (x-axis) correction in radians
  14794. * @param rollCor optional roll (z-axis) correction in radians
  14795. * @returns this TransformNode
  14796. */
  14797. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14798. /**
  14799. * Sets a new pivot point to the current node
  14800. * @param point defines the new pivot point to use
  14801. * @param space defines if the point is in world or local space (local by default)
  14802. * @returns the current TransformNode
  14803. */
  14804. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14805. /**
  14806. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14807. * @returns the pivot point
  14808. */
  14809. getPivotPoint(): Vector3;
  14810. /**
  14811. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14812. * @param result the vector3 to store the result
  14813. * @returns this TransformNode.
  14814. */
  14815. getPivotPointToRef(result: Vector3): TransformNode;
  14816. /**
  14817. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14818. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14819. */
  14820. getAbsolutePivotPoint(): Vector3;
  14821. /**
  14822. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14823. * @param result vector3 to store the result
  14824. * @returns this TransformNode.
  14825. */
  14826. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14827. /**
  14828. * Defines the passed node as the parent of the current node.
  14829. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14830. * @see https://doc.babylonjs.com/how_to/parenting
  14831. * @param node the node ot set as the parent
  14832. * @returns this TransformNode.
  14833. */
  14834. setParent(node: Nullable<Node>): TransformNode;
  14835. private _nonUniformScaling;
  14836. /**
  14837. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14838. */
  14839. get nonUniformScaling(): boolean;
  14840. /** @hidden */
  14841. _updateNonUniformScalingState(value: boolean): boolean;
  14842. /**
  14843. * Attach the current TransformNode to another TransformNode associated with a bone
  14844. * @param bone Bone affecting the TransformNode
  14845. * @param affectedTransformNode TransformNode associated with the bone
  14846. * @returns this object
  14847. */
  14848. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14849. /**
  14850. * Detach the transform node if its associated with a bone
  14851. * @returns this object
  14852. */
  14853. detachFromBone(): TransformNode;
  14854. private static _rotationAxisCache;
  14855. /**
  14856. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14857. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14858. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14859. * The passed axis is also normalized.
  14860. * @param axis the axis to rotate around
  14861. * @param amount the amount to rotate in radians
  14862. * @param space Space to rotate in (Default: local)
  14863. * @returns the TransformNode.
  14864. */
  14865. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14866. /**
  14867. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14868. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14869. * The passed axis is also normalized. .
  14870. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14871. * @param point the point to rotate around
  14872. * @param axis the axis to rotate around
  14873. * @param amount the amount to rotate in radians
  14874. * @returns the TransformNode
  14875. */
  14876. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14877. /**
  14878. * Translates the mesh along the axis vector for the passed distance in the given space.
  14879. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14880. * @param axis the axis to translate in
  14881. * @param distance the distance to translate
  14882. * @param space Space to rotate in (Default: local)
  14883. * @returns the TransformNode.
  14884. */
  14885. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14886. /**
  14887. * Adds a rotation step to the mesh current rotation.
  14888. * x, y, z are Euler angles expressed in radians.
  14889. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14890. * This means this rotation is made in the mesh local space only.
  14891. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14892. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14893. * ```javascript
  14894. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14895. * ```
  14896. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14897. * 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.
  14898. * @param x Rotation to add
  14899. * @param y Rotation to add
  14900. * @param z Rotation to add
  14901. * @returns the TransformNode.
  14902. */
  14903. addRotation(x: number, y: number, z: number): TransformNode;
  14904. /**
  14905. * @hidden
  14906. */
  14907. protected _getEffectiveParent(): Nullable<Node>;
  14908. /**
  14909. * Computes the world matrix of the node
  14910. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14911. * @returns the world matrix
  14912. */
  14913. computeWorldMatrix(force?: boolean): Matrix;
  14914. /**
  14915. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14916. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14917. */
  14918. resetLocalMatrix(independentOfChildren?: boolean): void;
  14919. protected _afterComputeWorldMatrix(): void;
  14920. /**
  14921. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14922. * @param func callback function to add
  14923. *
  14924. * @returns the TransformNode.
  14925. */
  14926. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14927. /**
  14928. * Removes a registered callback function.
  14929. * @param func callback function to remove
  14930. * @returns the TransformNode.
  14931. */
  14932. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14933. /**
  14934. * Gets the position of the current mesh in camera space
  14935. * @param camera defines the camera to use
  14936. * @returns a position
  14937. */
  14938. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14939. /**
  14940. * Returns the distance from the mesh to the active camera
  14941. * @param camera defines the camera to use
  14942. * @returns the distance
  14943. */
  14944. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14945. /**
  14946. * Clone the current transform node
  14947. * @param name Name of the new clone
  14948. * @param newParent New parent for the clone
  14949. * @param doNotCloneChildren Do not clone children hierarchy
  14950. * @returns the new transform node
  14951. */
  14952. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14953. /**
  14954. * Serializes the objects information.
  14955. * @param currentSerializationObject defines the object to serialize in
  14956. * @returns the serialized object
  14957. */
  14958. serialize(currentSerializationObject?: any): any;
  14959. /**
  14960. * Returns a new TransformNode object parsed from the source provided.
  14961. * @param parsedTransformNode is the source.
  14962. * @param scene the scne the object belongs to
  14963. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14964. * @returns a new TransformNode object parsed from the source provided.
  14965. */
  14966. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14967. /**
  14968. * Get all child-transformNodes of this node
  14969. * @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
  14970. * @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
  14971. * @returns an array of TransformNode
  14972. */
  14973. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14974. /**
  14975. * Releases resources associated with this transform node.
  14976. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14977. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14978. */
  14979. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14980. /**
  14981. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14982. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14983. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14984. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14985. * @returns the current mesh
  14986. */
  14987. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14988. private _syncAbsoluteScalingAndRotation;
  14989. }
  14990. }
  14991. declare module BABYLON {
  14992. /**
  14993. * Class used to override all child animations of a given target
  14994. */
  14995. export class AnimationPropertiesOverride {
  14996. /**
  14997. * Gets or sets a value indicating if animation blending must be used
  14998. */
  14999. enableBlending: boolean;
  15000. /**
  15001. * Gets or sets the blending speed to use when enableBlending is true
  15002. */
  15003. blendingSpeed: number;
  15004. /**
  15005. * Gets or sets the default loop mode to use
  15006. */
  15007. loopMode: number;
  15008. }
  15009. }
  15010. declare module BABYLON {
  15011. /**
  15012. * Class used to store bone information
  15013. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15014. */
  15015. export class Bone extends Node {
  15016. /**
  15017. * defines the bone name
  15018. */
  15019. name: string;
  15020. private static _tmpVecs;
  15021. private static _tmpQuat;
  15022. private static _tmpMats;
  15023. /**
  15024. * Gets the list of child bones
  15025. */
  15026. children: Bone[];
  15027. /** Gets the animations associated with this bone */
  15028. animations: Animation[];
  15029. /**
  15030. * Gets or sets bone length
  15031. */
  15032. length: number;
  15033. /**
  15034. * @hidden Internal only
  15035. * Set this value to map this bone to a different index in the transform matrices
  15036. * Set this value to -1 to exclude the bone from the transform matrices
  15037. */
  15038. _index: Nullable<number>;
  15039. private _skeleton;
  15040. private _localMatrix;
  15041. private _restPose;
  15042. private _baseMatrix;
  15043. private _absoluteTransform;
  15044. private _invertedAbsoluteTransform;
  15045. private _parent;
  15046. private _scalingDeterminant;
  15047. private _worldTransform;
  15048. private _localScaling;
  15049. private _localRotation;
  15050. private _localPosition;
  15051. private _needToDecompose;
  15052. private _needToCompose;
  15053. /** @hidden */
  15054. _linkedTransformNode: Nullable<TransformNode>;
  15055. /** @hidden */
  15056. _waitingTransformNodeId: Nullable<string>;
  15057. /** @hidden */
  15058. get _matrix(): Matrix;
  15059. /** @hidden */
  15060. set _matrix(value: Matrix);
  15061. /**
  15062. * Create a new bone
  15063. * @param name defines the bone name
  15064. * @param skeleton defines the parent skeleton
  15065. * @param parentBone defines the parent (can be null if the bone is the root)
  15066. * @param localMatrix defines the local matrix
  15067. * @param restPose defines the rest pose matrix
  15068. * @param baseMatrix defines the base matrix
  15069. * @param index defines index of the bone in the hiearchy
  15070. */
  15071. constructor(
  15072. /**
  15073. * defines the bone name
  15074. */
  15075. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15076. /**
  15077. * Gets the current object class name.
  15078. * @return the class name
  15079. */
  15080. getClassName(): string;
  15081. /**
  15082. * Gets the parent skeleton
  15083. * @returns a skeleton
  15084. */
  15085. getSkeleton(): Skeleton;
  15086. /**
  15087. * Gets parent bone
  15088. * @returns a bone or null if the bone is the root of the bone hierarchy
  15089. */
  15090. getParent(): Nullable<Bone>;
  15091. /**
  15092. * Returns an array containing the root bones
  15093. * @returns an array containing the root bones
  15094. */
  15095. getChildren(): Array<Bone>;
  15096. /**
  15097. * Gets the node index in matrix array generated for rendering
  15098. * @returns the node index
  15099. */
  15100. getIndex(): number;
  15101. /**
  15102. * Sets the parent bone
  15103. * @param parent defines the parent (can be null if the bone is the root)
  15104. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15105. */
  15106. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15107. /**
  15108. * Gets the local matrix
  15109. * @returns a matrix
  15110. */
  15111. getLocalMatrix(): Matrix;
  15112. /**
  15113. * Gets the base matrix (initial matrix which remains unchanged)
  15114. * @returns a matrix
  15115. */
  15116. getBaseMatrix(): Matrix;
  15117. /**
  15118. * Gets the rest pose matrix
  15119. * @returns a matrix
  15120. */
  15121. getRestPose(): Matrix;
  15122. /**
  15123. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15124. */
  15125. getWorldMatrix(): Matrix;
  15126. /**
  15127. * Sets the local matrix to rest pose matrix
  15128. */
  15129. returnToRest(): void;
  15130. /**
  15131. * Gets the inverse of the absolute transform matrix.
  15132. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15133. * @returns a matrix
  15134. */
  15135. getInvertedAbsoluteTransform(): Matrix;
  15136. /**
  15137. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15138. * @returns a matrix
  15139. */
  15140. getAbsoluteTransform(): Matrix;
  15141. /**
  15142. * Links with the given transform node.
  15143. * The local matrix of this bone is copied from the transform node every frame.
  15144. * @param transformNode defines the transform node to link to
  15145. */
  15146. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15147. /**
  15148. * Gets the node used to drive the bone's transformation
  15149. * @returns a transform node or null
  15150. */
  15151. getTransformNode(): Nullable<TransformNode>;
  15152. /** Gets or sets current position (in local space) */
  15153. get position(): Vector3;
  15154. set position(newPosition: Vector3);
  15155. /** Gets or sets current rotation (in local space) */
  15156. get rotation(): Vector3;
  15157. set rotation(newRotation: Vector3);
  15158. /** Gets or sets current rotation quaternion (in local space) */
  15159. get rotationQuaternion(): Quaternion;
  15160. set rotationQuaternion(newRotation: Quaternion);
  15161. /** Gets or sets current scaling (in local space) */
  15162. get scaling(): Vector3;
  15163. set scaling(newScaling: Vector3);
  15164. /**
  15165. * Gets the animation properties override
  15166. */
  15167. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15168. private _decompose;
  15169. private _compose;
  15170. /**
  15171. * Update the base and local matrices
  15172. * @param matrix defines the new base or local matrix
  15173. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15174. * @param updateLocalMatrix defines if the local matrix should be updated
  15175. */
  15176. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15177. /** @hidden */
  15178. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15179. /**
  15180. * Flag the bone as dirty (Forcing it to update everything)
  15181. */
  15182. markAsDirty(): void;
  15183. /** @hidden */
  15184. _markAsDirtyAndCompose(): void;
  15185. private _markAsDirtyAndDecompose;
  15186. /**
  15187. * Translate the bone in local or world space
  15188. * @param vec The amount to translate the bone
  15189. * @param space The space that the translation is in
  15190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15191. */
  15192. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15193. /**
  15194. * Set the postion of the bone in local or world space
  15195. * @param position The position to set the bone
  15196. * @param space The space that the position is in
  15197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15198. */
  15199. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15200. /**
  15201. * Set the absolute position of the bone (world space)
  15202. * @param position The position to set the bone
  15203. * @param mesh The mesh that this bone is attached to
  15204. */
  15205. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15206. /**
  15207. * Scale the bone on the x, y and z axes (in local space)
  15208. * @param x The amount to scale the bone on the x axis
  15209. * @param y The amount to scale the bone on the y axis
  15210. * @param z The amount to scale the bone on the z axis
  15211. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15212. */
  15213. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15214. /**
  15215. * Set the bone scaling in local space
  15216. * @param scale defines the scaling vector
  15217. */
  15218. setScale(scale: Vector3): void;
  15219. /**
  15220. * Gets the current scaling in local space
  15221. * @returns the current scaling vector
  15222. */
  15223. getScale(): Vector3;
  15224. /**
  15225. * Gets the current scaling in local space and stores it in a target vector
  15226. * @param result defines the target vector
  15227. */
  15228. getScaleToRef(result: Vector3): void;
  15229. /**
  15230. * Set the yaw, pitch, and roll of the bone in local or world space
  15231. * @param yaw The rotation of the bone on the y axis
  15232. * @param pitch The rotation of the bone on the x axis
  15233. * @param roll The rotation of the bone on the z axis
  15234. * @param space The space that the axes of rotation are in
  15235. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15236. */
  15237. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15238. /**
  15239. * Add a rotation to the bone on an axis in local or world space
  15240. * @param axis The axis to rotate the bone on
  15241. * @param amount The amount to rotate the bone
  15242. * @param space The space that the axis is in
  15243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15244. */
  15245. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15246. /**
  15247. * Set the rotation of the bone to a particular axis angle in local or world space
  15248. * @param axis The axis to rotate the bone on
  15249. * @param angle The angle that the bone should be rotated to
  15250. * @param space The space that the axis is in
  15251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15252. */
  15253. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15254. /**
  15255. * Set the euler rotation of the bone in local of world space
  15256. * @param rotation The euler rotation that the bone should be set to
  15257. * @param space The space that the rotation is in
  15258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15259. */
  15260. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15261. /**
  15262. * Set the quaternion rotation of the bone in local of world space
  15263. * @param quat The quaternion rotation that the bone should be set to
  15264. * @param space The space that the rotation is in
  15265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15266. */
  15267. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15268. /**
  15269. * Set the rotation matrix of the bone in local of world space
  15270. * @param rotMat The rotation matrix that the bone should be set to
  15271. * @param space The space that the rotation is in
  15272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15273. */
  15274. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15275. private _rotateWithMatrix;
  15276. private _getNegativeRotationToRef;
  15277. /**
  15278. * Get the position of the bone in local or world space
  15279. * @param space The space that the returned position is in
  15280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15281. * @returns The position of the bone
  15282. */
  15283. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15284. /**
  15285. * Copy the position of the bone to a vector3 in local or world space
  15286. * @param space The space that the returned position is in
  15287. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15288. * @param result The vector3 to copy the position to
  15289. */
  15290. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15291. /**
  15292. * Get the absolute position of the bone (world space)
  15293. * @param mesh The mesh that this bone is attached to
  15294. * @returns The absolute position of the bone
  15295. */
  15296. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15297. /**
  15298. * Copy the absolute position of the bone (world space) to the result param
  15299. * @param mesh The mesh that this bone is attached to
  15300. * @param result The vector3 to copy the absolute position to
  15301. */
  15302. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15303. /**
  15304. * Compute the absolute transforms of this bone and its children
  15305. */
  15306. computeAbsoluteTransforms(): void;
  15307. /**
  15308. * Get the world direction from an axis that is in the local space of the bone
  15309. * @param localAxis The local direction that is used to compute the world direction
  15310. * @param mesh The mesh that this bone is attached to
  15311. * @returns The world direction
  15312. */
  15313. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15314. /**
  15315. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15316. * @param localAxis The local direction that is used to compute the world direction
  15317. * @param mesh The mesh that this bone is attached to
  15318. * @param result The vector3 that the world direction will be copied to
  15319. */
  15320. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15321. /**
  15322. * Get the euler rotation of the bone in local or world space
  15323. * @param space The space that the rotation should be in
  15324. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15325. * @returns The euler rotation
  15326. */
  15327. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15328. /**
  15329. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15330. * @param space The space that the rotation should be in
  15331. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15332. * @param result The vector3 that the rotation should be copied to
  15333. */
  15334. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15335. /**
  15336. * Get the quaternion rotation of the bone in either local or world space
  15337. * @param space The space that the rotation should be in
  15338. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15339. * @returns The quaternion rotation
  15340. */
  15341. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15342. /**
  15343. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15344. * @param space The space that the rotation should be in
  15345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15346. * @param result The quaternion that the rotation should be copied to
  15347. */
  15348. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15349. /**
  15350. * Get the rotation matrix of the bone in local or world space
  15351. * @param space The space that the rotation should be in
  15352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15353. * @returns The rotation matrix
  15354. */
  15355. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15356. /**
  15357. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15358. * @param space The space that the rotation should be in
  15359. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15360. * @param result The quaternion that the rotation should be copied to
  15361. */
  15362. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15363. /**
  15364. * Get the world position of a point that is in the local space of the bone
  15365. * @param position The local position
  15366. * @param mesh The mesh that this bone is attached to
  15367. * @returns The world position
  15368. */
  15369. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15370. /**
  15371. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15372. * @param position The local position
  15373. * @param mesh The mesh that this bone is attached to
  15374. * @param result The vector3 that the world position should be copied to
  15375. */
  15376. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15377. /**
  15378. * Get the local position of a point that is in world space
  15379. * @param position The world position
  15380. * @param mesh The mesh that this bone is attached to
  15381. * @returns The local position
  15382. */
  15383. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15384. /**
  15385. * Get the local position of a point that is in world space and copy it to the result param
  15386. * @param position The world position
  15387. * @param mesh The mesh that this bone is attached to
  15388. * @param result The vector3 that the local position should be copied to
  15389. */
  15390. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15391. }
  15392. }
  15393. declare module BABYLON {
  15394. /**
  15395. * Defines a runtime animation
  15396. */
  15397. export class RuntimeAnimation {
  15398. private _events;
  15399. /**
  15400. * The current frame of the runtime animation
  15401. */
  15402. private _currentFrame;
  15403. /**
  15404. * The animation used by the runtime animation
  15405. */
  15406. private _animation;
  15407. /**
  15408. * The target of the runtime animation
  15409. */
  15410. private _target;
  15411. /**
  15412. * The initiating animatable
  15413. */
  15414. private _host;
  15415. /**
  15416. * The original value of the runtime animation
  15417. */
  15418. private _originalValue;
  15419. /**
  15420. * The original blend value of the runtime animation
  15421. */
  15422. private _originalBlendValue;
  15423. /**
  15424. * The offsets cache of the runtime animation
  15425. */
  15426. private _offsetsCache;
  15427. /**
  15428. * The high limits cache of the runtime animation
  15429. */
  15430. private _highLimitsCache;
  15431. /**
  15432. * Specifies if the runtime animation has been stopped
  15433. */
  15434. private _stopped;
  15435. /**
  15436. * The blending factor of the runtime animation
  15437. */
  15438. private _blendingFactor;
  15439. /**
  15440. * The BabylonJS scene
  15441. */
  15442. private _scene;
  15443. /**
  15444. * The current value of the runtime animation
  15445. */
  15446. private _currentValue;
  15447. /** @hidden */
  15448. _animationState: _IAnimationState;
  15449. /**
  15450. * The active target of the runtime animation
  15451. */
  15452. private _activeTargets;
  15453. private _currentActiveTarget;
  15454. private _directTarget;
  15455. /**
  15456. * The target path of the runtime animation
  15457. */
  15458. private _targetPath;
  15459. /**
  15460. * The weight of the runtime animation
  15461. */
  15462. private _weight;
  15463. /**
  15464. * The ratio offset of the runtime animation
  15465. */
  15466. private _ratioOffset;
  15467. /**
  15468. * The previous delay of the runtime animation
  15469. */
  15470. private _previousDelay;
  15471. /**
  15472. * The previous ratio of the runtime animation
  15473. */
  15474. private _previousRatio;
  15475. private _enableBlending;
  15476. private _keys;
  15477. private _minFrame;
  15478. private _maxFrame;
  15479. private _minValue;
  15480. private _maxValue;
  15481. private _targetIsArray;
  15482. /**
  15483. * Gets the current frame of the runtime animation
  15484. */
  15485. get currentFrame(): number;
  15486. /**
  15487. * Gets the weight of the runtime animation
  15488. */
  15489. get weight(): number;
  15490. /**
  15491. * Gets the current value of the runtime animation
  15492. */
  15493. get currentValue(): any;
  15494. /**
  15495. * Gets the target path of the runtime animation
  15496. */
  15497. get targetPath(): string;
  15498. /**
  15499. * Gets the actual target of the runtime animation
  15500. */
  15501. get target(): any;
  15502. /**
  15503. * Gets the additive state of the runtime animation
  15504. */
  15505. get isAdditive(): boolean;
  15506. /** @hidden */
  15507. _onLoop: () => void;
  15508. /**
  15509. * Create a new RuntimeAnimation object
  15510. * @param target defines the target of the animation
  15511. * @param animation defines the source animation object
  15512. * @param scene defines the hosting scene
  15513. * @param host defines the initiating Animatable
  15514. */
  15515. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15516. private _preparePath;
  15517. /**
  15518. * Gets the animation from the runtime animation
  15519. */
  15520. get animation(): Animation;
  15521. /**
  15522. * Resets the runtime animation to the beginning
  15523. * @param restoreOriginal defines whether to restore the target property to the original value
  15524. */
  15525. reset(restoreOriginal?: boolean): void;
  15526. /**
  15527. * Specifies if the runtime animation is stopped
  15528. * @returns Boolean specifying if the runtime animation is stopped
  15529. */
  15530. isStopped(): boolean;
  15531. /**
  15532. * Disposes of the runtime animation
  15533. */
  15534. dispose(): void;
  15535. /**
  15536. * Apply the interpolated value to the target
  15537. * @param currentValue defines the value computed by the animation
  15538. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15539. */
  15540. setValue(currentValue: any, weight: number): void;
  15541. private _getOriginalValues;
  15542. private _setValue;
  15543. /**
  15544. * Gets the loop pmode of the runtime animation
  15545. * @returns Loop Mode
  15546. */
  15547. private _getCorrectLoopMode;
  15548. /**
  15549. * Move the current animation to a given frame
  15550. * @param frame defines the frame to move to
  15551. */
  15552. goToFrame(frame: number): void;
  15553. /**
  15554. * @hidden Internal use only
  15555. */
  15556. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15557. /**
  15558. * Execute the current animation
  15559. * @param delay defines the delay to add to the current frame
  15560. * @param from defines the lower bound of the animation range
  15561. * @param to defines the upper bound of the animation range
  15562. * @param loop defines if the current animation must loop
  15563. * @param speedRatio defines the current speed ratio
  15564. * @param weight defines the weight of the animation (default is -1 so no weight)
  15565. * @param onLoop optional callback called when animation loops
  15566. * @returns a boolean indicating if the animation is running
  15567. */
  15568. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15569. }
  15570. }
  15571. declare module BABYLON {
  15572. /**
  15573. * Class used to store an actual running animation
  15574. */
  15575. export class Animatable {
  15576. /** defines the target object */
  15577. target: any;
  15578. /** defines the starting frame number (default is 0) */
  15579. fromFrame: number;
  15580. /** defines the ending frame number (default is 100) */
  15581. toFrame: number;
  15582. /** defines if the animation must loop (default is false) */
  15583. loopAnimation: boolean;
  15584. /** defines a callback to call when animation ends if it is not looping */
  15585. onAnimationEnd?: (() => void) | null | undefined;
  15586. /** defines a callback to call when animation loops */
  15587. onAnimationLoop?: (() => void) | null | undefined;
  15588. /** defines whether the animation should be evaluated additively */
  15589. isAdditive: boolean;
  15590. private _localDelayOffset;
  15591. private _pausedDelay;
  15592. private _runtimeAnimations;
  15593. private _paused;
  15594. private _scene;
  15595. private _speedRatio;
  15596. private _weight;
  15597. private _syncRoot;
  15598. /**
  15599. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15600. * This will only apply for non looping animation (default is true)
  15601. */
  15602. disposeOnEnd: boolean;
  15603. /**
  15604. * Gets a boolean indicating if the animation has started
  15605. */
  15606. animationStarted: boolean;
  15607. /**
  15608. * Observer raised when the animation ends
  15609. */
  15610. onAnimationEndObservable: Observable<Animatable>;
  15611. /**
  15612. * Observer raised when the animation loops
  15613. */
  15614. onAnimationLoopObservable: Observable<Animatable>;
  15615. /**
  15616. * Gets the root Animatable used to synchronize and normalize animations
  15617. */
  15618. get syncRoot(): Nullable<Animatable>;
  15619. /**
  15620. * Gets the current frame of the first RuntimeAnimation
  15621. * Used to synchronize Animatables
  15622. */
  15623. get masterFrame(): number;
  15624. /**
  15625. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15626. */
  15627. get weight(): number;
  15628. set weight(value: number);
  15629. /**
  15630. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15631. */
  15632. get speedRatio(): number;
  15633. set speedRatio(value: number);
  15634. /**
  15635. * Creates a new Animatable
  15636. * @param scene defines the hosting scene
  15637. * @param target defines the target object
  15638. * @param fromFrame defines the starting frame number (default is 0)
  15639. * @param toFrame defines the ending frame number (default is 100)
  15640. * @param loopAnimation defines if the animation must loop (default is false)
  15641. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15642. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15643. * @param animations defines a group of animation to add to the new Animatable
  15644. * @param onAnimationLoop defines a callback to call when animation loops
  15645. * @param isAdditive defines whether the animation should be evaluated additively
  15646. */
  15647. constructor(scene: Scene,
  15648. /** defines the target object */
  15649. target: any,
  15650. /** defines the starting frame number (default is 0) */
  15651. fromFrame?: number,
  15652. /** defines the ending frame number (default is 100) */
  15653. toFrame?: number,
  15654. /** defines if the animation must loop (default is false) */
  15655. loopAnimation?: boolean, speedRatio?: number,
  15656. /** defines a callback to call when animation ends if it is not looping */
  15657. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15658. /** defines a callback to call when animation loops */
  15659. onAnimationLoop?: (() => void) | null | undefined,
  15660. /** defines whether the animation should be evaluated additively */
  15661. isAdditive?: boolean);
  15662. /**
  15663. * Synchronize and normalize current Animatable with a source Animatable
  15664. * This is useful when using animation weights and when animations are not of the same length
  15665. * @param root defines the root Animatable to synchronize with
  15666. * @returns the current Animatable
  15667. */
  15668. syncWith(root: Animatable): Animatable;
  15669. /**
  15670. * Gets the list of runtime animations
  15671. * @returns an array of RuntimeAnimation
  15672. */
  15673. getAnimations(): RuntimeAnimation[];
  15674. /**
  15675. * Adds more animations to the current animatable
  15676. * @param target defines the target of the animations
  15677. * @param animations defines the new animations to add
  15678. */
  15679. appendAnimations(target: any, animations: Animation[]): void;
  15680. /**
  15681. * Gets the source animation for a specific property
  15682. * @param property defines the propertyu to look for
  15683. * @returns null or the source animation for the given property
  15684. */
  15685. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15686. /**
  15687. * Gets the runtime animation for a specific property
  15688. * @param property defines the propertyu to look for
  15689. * @returns null or the runtime animation for the given property
  15690. */
  15691. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15692. /**
  15693. * Resets the animatable to its original state
  15694. */
  15695. reset(): void;
  15696. /**
  15697. * Allows the animatable to blend with current running animations
  15698. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15699. * @param blendingSpeed defines the blending speed to use
  15700. */
  15701. enableBlending(blendingSpeed: number): void;
  15702. /**
  15703. * Disable animation blending
  15704. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15705. */
  15706. disableBlending(): void;
  15707. /**
  15708. * Jump directly to a given frame
  15709. * @param frame defines the frame to jump to
  15710. */
  15711. goToFrame(frame: number): void;
  15712. /**
  15713. * Pause the animation
  15714. */
  15715. pause(): void;
  15716. /**
  15717. * Restart the animation
  15718. */
  15719. restart(): void;
  15720. private _raiseOnAnimationEnd;
  15721. /**
  15722. * Stop and delete the current animation
  15723. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15724. * @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)
  15725. */
  15726. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15727. /**
  15728. * Wait asynchronously for the animation to end
  15729. * @returns a promise which will be fullfilled when the animation ends
  15730. */
  15731. waitAsync(): Promise<Animatable>;
  15732. /** @hidden */
  15733. _animate(delay: number): boolean;
  15734. }
  15735. interface Scene {
  15736. /** @hidden */
  15737. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15738. /** @hidden */
  15739. _processLateAnimationBindingsForMatrices(holder: {
  15740. totalWeight: number;
  15741. totalAdditiveWeight: number;
  15742. animations: RuntimeAnimation[];
  15743. additiveAnimations: RuntimeAnimation[];
  15744. originalValue: Matrix;
  15745. }): any;
  15746. /** @hidden */
  15747. _processLateAnimationBindingsForQuaternions(holder: {
  15748. totalWeight: number;
  15749. totalAdditiveWeight: number;
  15750. animations: RuntimeAnimation[];
  15751. additiveAnimations: RuntimeAnimation[];
  15752. originalValue: Quaternion;
  15753. }, refQuaternion: Quaternion): Quaternion;
  15754. /** @hidden */
  15755. _processLateAnimationBindings(): void;
  15756. /**
  15757. * Will start the animation sequence of a given target
  15758. * @param target defines the target
  15759. * @param from defines from which frame should animation start
  15760. * @param to defines until which frame should animation run.
  15761. * @param weight defines the weight to apply to the animation (1.0 by default)
  15762. * @param loop defines if the animation loops
  15763. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15764. * @param onAnimationEnd defines the function to be executed when the animation ends
  15765. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15766. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15767. * @param onAnimationLoop defines the callback to call when an animation loops
  15768. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15769. * @returns the animatable object created for this animation
  15770. */
  15771. 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;
  15772. /**
  15773. * Will start the animation sequence of a given target
  15774. * @param target defines the target
  15775. * @param from defines from which frame should animation start
  15776. * @param to defines until which frame should animation run.
  15777. * @param loop defines if the animation loops
  15778. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15779. * @param onAnimationEnd defines the function to be executed when the animation ends
  15780. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15781. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15782. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15783. * @param onAnimationLoop defines the callback to call when an animation loops
  15784. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15785. * @returns the animatable object created for this animation
  15786. */
  15787. 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;
  15788. /**
  15789. * Will start the animation sequence of a given target and its hierarchy
  15790. * @param target defines the target
  15791. * @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.
  15792. * @param from defines from which frame should animation start
  15793. * @param to defines until which frame should animation run.
  15794. * @param loop defines if the animation loops
  15795. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15796. * @param onAnimationEnd defines the function to be executed when the animation ends
  15797. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15798. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15799. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15800. * @param onAnimationLoop defines the callback to call when an animation loops
  15801. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15802. * @returns the list of created animatables
  15803. */
  15804. 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[];
  15805. /**
  15806. * Begin a new animation on a given node
  15807. * @param target defines the target where the animation will take place
  15808. * @param animations defines the list of animations to start
  15809. * @param from defines the initial value
  15810. * @param to defines the final value
  15811. * @param loop defines if you want animation to loop (off by default)
  15812. * @param speedRatio defines the speed ratio to apply to all animations
  15813. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15814. * @param onAnimationLoop defines the callback to call when an animation loops
  15815. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15816. * @returns the list of created animatables
  15817. */
  15818. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15819. /**
  15820. * Begin a new animation on a given node and its hierarchy
  15821. * @param target defines the root node where the animation will take place
  15822. * @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.
  15823. * @param animations defines the list of animations to start
  15824. * @param from defines the initial value
  15825. * @param to defines the final value
  15826. * @param loop defines if you want animation to loop (off by default)
  15827. * @param speedRatio defines the speed ratio to apply to all animations
  15828. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15829. * @param onAnimationLoop defines the callback to call when an animation loops
  15830. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15831. * @returns the list of animatables created for all nodes
  15832. */
  15833. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15834. /**
  15835. * Gets the animatable associated with a specific target
  15836. * @param target defines the target of the animatable
  15837. * @returns the required animatable if found
  15838. */
  15839. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15840. /**
  15841. * Gets all animatables associated with a given target
  15842. * @param target defines the target to look animatables for
  15843. * @returns an array of Animatables
  15844. */
  15845. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15846. /**
  15847. * Stops and removes all animations that have been applied to the scene
  15848. */
  15849. stopAllAnimations(): void;
  15850. /**
  15851. * Gets the current delta time used by animation engine
  15852. */
  15853. deltaTime: number;
  15854. }
  15855. interface Bone {
  15856. /**
  15857. * Copy an animation range from another bone
  15858. * @param source defines the source bone
  15859. * @param rangeName defines the range name to copy
  15860. * @param frameOffset defines the frame offset
  15861. * @param rescaleAsRequired defines if rescaling must be applied if required
  15862. * @param skelDimensionsRatio defines the scaling ratio
  15863. * @returns true if operation was successful
  15864. */
  15865. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15866. }
  15867. }
  15868. declare module BABYLON {
  15869. /**
  15870. * Class used to handle skinning animations
  15871. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15872. */
  15873. export class Skeleton implements IAnimatable {
  15874. /** defines the skeleton name */
  15875. name: string;
  15876. /** defines the skeleton Id */
  15877. id: string;
  15878. /**
  15879. * Defines the list of child bones
  15880. */
  15881. bones: Bone[];
  15882. /**
  15883. * Defines an estimate of the dimension of the skeleton at rest
  15884. */
  15885. dimensionsAtRest: Vector3;
  15886. /**
  15887. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15888. */
  15889. needInitialSkinMatrix: boolean;
  15890. /**
  15891. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15892. */
  15893. overrideMesh: Nullable<AbstractMesh>;
  15894. /**
  15895. * Gets the list of animations attached to this skeleton
  15896. */
  15897. animations: Array<Animation>;
  15898. private _scene;
  15899. private _isDirty;
  15900. private _transformMatrices;
  15901. private _transformMatrixTexture;
  15902. private _meshesWithPoseMatrix;
  15903. private _animatables;
  15904. private _identity;
  15905. private _synchronizedWithMesh;
  15906. private _ranges;
  15907. private _lastAbsoluteTransformsUpdateId;
  15908. private _canUseTextureForBones;
  15909. private _uniqueId;
  15910. /** @hidden */
  15911. _numBonesWithLinkedTransformNode: number;
  15912. /** @hidden */
  15913. _hasWaitingData: Nullable<boolean>;
  15914. /**
  15915. * Specifies if the skeleton should be serialized
  15916. */
  15917. doNotSerialize: boolean;
  15918. private _useTextureToStoreBoneMatrices;
  15919. /**
  15920. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15921. * Please note that this option is not available if the hardware does not support it
  15922. */
  15923. get useTextureToStoreBoneMatrices(): boolean;
  15924. set useTextureToStoreBoneMatrices(value: boolean);
  15925. private _animationPropertiesOverride;
  15926. /**
  15927. * Gets or sets the animation properties override
  15928. */
  15929. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15930. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15931. /**
  15932. * List of inspectable custom properties (used by the Inspector)
  15933. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15934. */
  15935. inspectableCustomProperties: IInspectable[];
  15936. /**
  15937. * An observable triggered before computing the skeleton's matrices
  15938. */
  15939. onBeforeComputeObservable: Observable<Skeleton>;
  15940. /**
  15941. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15942. */
  15943. get isUsingTextureForMatrices(): boolean;
  15944. /**
  15945. * Gets the unique ID of this skeleton
  15946. */
  15947. get uniqueId(): number;
  15948. /**
  15949. * Creates a new skeleton
  15950. * @param name defines the skeleton name
  15951. * @param id defines the skeleton Id
  15952. * @param scene defines the hosting scene
  15953. */
  15954. constructor(
  15955. /** defines the skeleton name */
  15956. name: string,
  15957. /** defines the skeleton Id */
  15958. id: string, scene: Scene);
  15959. /**
  15960. * Gets the current object class name.
  15961. * @return the class name
  15962. */
  15963. getClassName(): string;
  15964. /**
  15965. * Returns an array containing the root bones
  15966. * @returns an array containing the root bones
  15967. */
  15968. getChildren(): Array<Bone>;
  15969. /**
  15970. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15971. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15972. * @returns a Float32Array containing matrices data
  15973. */
  15974. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15975. /**
  15976. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15977. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15978. * @returns a raw texture containing the data
  15979. */
  15980. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15981. /**
  15982. * Gets the current hosting scene
  15983. * @returns a scene object
  15984. */
  15985. getScene(): Scene;
  15986. /**
  15987. * Gets a string representing the current skeleton data
  15988. * @param fullDetails defines a boolean indicating if we want a verbose version
  15989. * @returns a string representing the current skeleton data
  15990. */
  15991. toString(fullDetails?: boolean): string;
  15992. /**
  15993. * Get bone's index searching by name
  15994. * @param name defines bone's name to search for
  15995. * @return the indice of the bone. Returns -1 if not found
  15996. */
  15997. getBoneIndexByName(name: string): number;
  15998. /**
  15999. * Creater a new animation range
  16000. * @param name defines the name of the range
  16001. * @param from defines the start key
  16002. * @param to defines the end key
  16003. */
  16004. createAnimationRange(name: string, from: number, to: number): void;
  16005. /**
  16006. * Delete a specific animation range
  16007. * @param name defines the name of the range
  16008. * @param deleteFrames defines if frames must be removed as well
  16009. */
  16010. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16011. /**
  16012. * Gets a specific animation range
  16013. * @param name defines the name of the range to look for
  16014. * @returns the requested animation range or null if not found
  16015. */
  16016. getAnimationRange(name: string): Nullable<AnimationRange>;
  16017. /**
  16018. * Gets the list of all animation ranges defined on this skeleton
  16019. * @returns an array
  16020. */
  16021. getAnimationRanges(): Nullable<AnimationRange>[];
  16022. /**
  16023. * Copy animation range from a source skeleton.
  16024. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16025. * @param source defines the source skeleton
  16026. * @param name defines the name of the range to copy
  16027. * @param rescaleAsRequired defines if rescaling must be applied if required
  16028. * @returns true if operation was successful
  16029. */
  16030. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16031. /**
  16032. * Forces the skeleton to go to rest pose
  16033. */
  16034. returnToRest(): void;
  16035. private _getHighestAnimationFrame;
  16036. /**
  16037. * Begin a specific animation range
  16038. * @param name defines the name of the range to start
  16039. * @param loop defines if looping must be turned on (false by default)
  16040. * @param speedRatio defines the speed ratio to apply (1 by default)
  16041. * @param onAnimationEnd defines a callback which will be called when animation will end
  16042. * @returns a new animatable
  16043. */
  16044. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16045. /**
  16046. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16047. * @param skeleton defines the Skeleton containing the animation range to convert
  16048. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16049. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16050. * @returns the original skeleton
  16051. */
  16052. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16053. /** @hidden */
  16054. _markAsDirty(): void;
  16055. /** @hidden */
  16056. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16057. /** @hidden */
  16058. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16059. private _computeTransformMatrices;
  16060. /**
  16061. * Build all resources required to render a skeleton
  16062. */
  16063. prepare(): void;
  16064. /**
  16065. * Gets the list of animatables currently running for this skeleton
  16066. * @returns an array of animatables
  16067. */
  16068. getAnimatables(): IAnimatable[];
  16069. /**
  16070. * Clone the current skeleton
  16071. * @param name defines the name of the new skeleton
  16072. * @param id defines the id of the new skeleton
  16073. * @returns the new skeleton
  16074. */
  16075. clone(name: string, id?: string): Skeleton;
  16076. /**
  16077. * Enable animation blending for this skeleton
  16078. * @param blendingSpeed defines the blending speed to apply
  16079. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16080. */
  16081. enableBlending(blendingSpeed?: number): void;
  16082. /**
  16083. * Releases all resources associated with the current skeleton
  16084. */
  16085. dispose(): void;
  16086. /**
  16087. * Serialize the skeleton in a JSON object
  16088. * @returns a JSON object
  16089. */
  16090. serialize(): any;
  16091. /**
  16092. * Creates a new skeleton from serialized data
  16093. * @param parsedSkeleton defines the serialized data
  16094. * @param scene defines the hosting scene
  16095. * @returns a new skeleton
  16096. */
  16097. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16098. /**
  16099. * Compute all node absolute transforms
  16100. * @param forceUpdate defines if computation must be done even if cache is up to date
  16101. */
  16102. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16103. /**
  16104. * Gets the root pose matrix
  16105. * @returns a matrix
  16106. */
  16107. getPoseMatrix(): Nullable<Matrix>;
  16108. /**
  16109. * Sorts bones per internal index
  16110. */
  16111. sortBones(): void;
  16112. private _sortBones;
  16113. }
  16114. }
  16115. declare module BABYLON {
  16116. /**
  16117. * Creates an instance based on a source mesh.
  16118. */
  16119. export class InstancedMesh extends AbstractMesh {
  16120. private _sourceMesh;
  16121. private _currentLOD;
  16122. /** @hidden */
  16123. _indexInSourceMeshInstanceArray: number;
  16124. constructor(name: string, source: Mesh);
  16125. /**
  16126. * Returns the string "InstancedMesh".
  16127. */
  16128. getClassName(): string;
  16129. /** Gets the list of lights affecting that mesh */
  16130. get lightSources(): Light[];
  16131. _resyncLightSources(): void;
  16132. _resyncLightSource(light: Light): void;
  16133. _removeLightSource(light: Light, dispose: boolean): void;
  16134. /**
  16135. * If the source mesh receives shadows
  16136. */
  16137. get receiveShadows(): boolean;
  16138. /**
  16139. * The material of the source mesh
  16140. */
  16141. get material(): Nullable<Material>;
  16142. /**
  16143. * Visibility of the source mesh
  16144. */
  16145. get visibility(): number;
  16146. /**
  16147. * Skeleton of the source mesh
  16148. */
  16149. get skeleton(): Nullable<Skeleton>;
  16150. /**
  16151. * Rendering ground id of the source mesh
  16152. */
  16153. get renderingGroupId(): number;
  16154. set renderingGroupId(value: number);
  16155. /**
  16156. * Returns the total number of vertices (integer).
  16157. */
  16158. getTotalVertices(): number;
  16159. /**
  16160. * Returns a positive integer : the total number of indices in this mesh geometry.
  16161. * @returns the numner of indices or zero if the mesh has no geometry.
  16162. */
  16163. getTotalIndices(): number;
  16164. /**
  16165. * The source mesh of the instance
  16166. */
  16167. get sourceMesh(): Mesh;
  16168. /**
  16169. * Creates a new InstancedMesh object from the mesh model.
  16170. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16171. * @param name defines the name of the new instance
  16172. * @returns a new InstancedMesh
  16173. */
  16174. createInstance(name: string): InstancedMesh;
  16175. /**
  16176. * Is this node ready to be used/rendered
  16177. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16178. * @return {boolean} is it ready
  16179. */
  16180. isReady(completeCheck?: boolean): boolean;
  16181. /**
  16182. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16183. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16184. * @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.
  16185. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16186. */
  16187. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16188. /**
  16189. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16190. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16191. * The `data` are either a numeric array either a Float32Array.
  16192. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16193. * 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).
  16194. * Note that a new underlying VertexBuffer object is created each call.
  16195. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16196. *
  16197. * Possible `kind` values :
  16198. * - VertexBuffer.PositionKind
  16199. * - VertexBuffer.UVKind
  16200. * - VertexBuffer.UV2Kind
  16201. * - VertexBuffer.UV3Kind
  16202. * - VertexBuffer.UV4Kind
  16203. * - VertexBuffer.UV5Kind
  16204. * - VertexBuffer.UV6Kind
  16205. * - VertexBuffer.ColorKind
  16206. * - VertexBuffer.MatricesIndicesKind
  16207. * - VertexBuffer.MatricesIndicesExtraKind
  16208. * - VertexBuffer.MatricesWeightsKind
  16209. * - VertexBuffer.MatricesWeightsExtraKind
  16210. *
  16211. * Returns the Mesh.
  16212. */
  16213. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16214. /**
  16215. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16216. * If the mesh has no geometry, it is simply returned as it is.
  16217. * The `data` are either a numeric array either a Float32Array.
  16218. * No new underlying VertexBuffer object is created.
  16219. * 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.
  16220. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16221. *
  16222. * Possible `kind` values :
  16223. * - VertexBuffer.PositionKind
  16224. * - VertexBuffer.UVKind
  16225. * - VertexBuffer.UV2Kind
  16226. * - VertexBuffer.UV3Kind
  16227. * - VertexBuffer.UV4Kind
  16228. * - VertexBuffer.UV5Kind
  16229. * - VertexBuffer.UV6Kind
  16230. * - VertexBuffer.ColorKind
  16231. * - VertexBuffer.MatricesIndicesKind
  16232. * - VertexBuffer.MatricesIndicesExtraKind
  16233. * - VertexBuffer.MatricesWeightsKind
  16234. * - VertexBuffer.MatricesWeightsExtraKind
  16235. *
  16236. * Returns the Mesh.
  16237. */
  16238. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16239. /**
  16240. * Sets the mesh indices.
  16241. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16242. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16243. * This method creates a new index buffer each call.
  16244. * Returns the Mesh.
  16245. */
  16246. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16247. /**
  16248. * Boolean : True if the mesh owns the requested kind of data.
  16249. */
  16250. isVerticesDataPresent(kind: string): boolean;
  16251. /**
  16252. * Returns an array of indices (IndicesArray).
  16253. */
  16254. getIndices(): Nullable<IndicesArray>;
  16255. get _positions(): Nullable<Vector3[]>;
  16256. /**
  16257. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16258. * This means the mesh underlying bounding box and sphere are recomputed.
  16259. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16260. * @returns the current mesh
  16261. */
  16262. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16263. /** @hidden */
  16264. _preActivate(): InstancedMesh;
  16265. /** @hidden */
  16266. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16267. /** @hidden */
  16268. _postActivate(): void;
  16269. getWorldMatrix(): Matrix;
  16270. get isAnInstance(): boolean;
  16271. /**
  16272. * Returns the current associated LOD AbstractMesh.
  16273. */
  16274. getLOD(camera: Camera): AbstractMesh;
  16275. /** @hidden */
  16276. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16277. /** @hidden */
  16278. _syncSubMeshes(): InstancedMesh;
  16279. /** @hidden */
  16280. _generatePointsArray(): boolean;
  16281. /**
  16282. * Creates a new InstancedMesh from the current mesh.
  16283. * - name (string) : the cloned mesh name
  16284. * - newParent (optional Node) : the optional Node to parent the clone to.
  16285. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16286. *
  16287. * Returns the clone.
  16288. */
  16289. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16290. /**
  16291. * Disposes the InstancedMesh.
  16292. * Returns nothing.
  16293. */
  16294. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16295. }
  16296. interface Mesh {
  16297. /**
  16298. * Register a custom buffer that will be instanced
  16299. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16300. * @param kind defines the buffer kind
  16301. * @param stride defines the stride in floats
  16302. */
  16303. registerInstancedBuffer(kind: string, stride: number): void;
  16304. /** @hidden */
  16305. _userInstancedBuffersStorage: {
  16306. data: {
  16307. [key: string]: Float32Array;
  16308. };
  16309. sizes: {
  16310. [key: string]: number;
  16311. };
  16312. vertexBuffers: {
  16313. [key: string]: Nullable<VertexBuffer>;
  16314. };
  16315. strides: {
  16316. [key: string]: number;
  16317. };
  16318. };
  16319. }
  16320. interface AbstractMesh {
  16321. /**
  16322. * Object used to store instanced buffers defined by user
  16323. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16324. */
  16325. instancedBuffers: {
  16326. [key: string]: any;
  16327. };
  16328. }
  16329. }
  16330. declare module BABYLON {
  16331. /**
  16332. * Defines the options associated with the creation of a shader material.
  16333. */
  16334. export interface IShaderMaterialOptions {
  16335. /**
  16336. * Does the material work in alpha blend mode
  16337. */
  16338. needAlphaBlending: boolean;
  16339. /**
  16340. * Does the material work in alpha test mode
  16341. */
  16342. needAlphaTesting: boolean;
  16343. /**
  16344. * The list of attribute names used in the shader
  16345. */
  16346. attributes: string[];
  16347. /**
  16348. * The list of unifrom names used in the shader
  16349. */
  16350. uniforms: string[];
  16351. /**
  16352. * The list of UBO names used in the shader
  16353. */
  16354. uniformBuffers: string[];
  16355. /**
  16356. * The list of sampler names used in the shader
  16357. */
  16358. samplers: string[];
  16359. /**
  16360. * The list of defines used in the shader
  16361. */
  16362. defines: string[];
  16363. }
  16364. /**
  16365. * 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.
  16366. *
  16367. * This returned material effects how the mesh will look based on the code in the shaders.
  16368. *
  16369. * @see http://doc.babylonjs.com/how_to/shader_material
  16370. */
  16371. export class ShaderMaterial extends Material {
  16372. private _shaderPath;
  16373. private _options;
  16374. private _textures;
  16375. private _textureArrays;
  16376. private _floats;
  16377. private _ints;
  16378. private _floatsArrays;
  16379. private _colors3;
  16380. private _colors3Arrays;
  16381. private _colors4;
  16382. private _colors4Arrays;
  16383. private _vectors2;
  16384. private _vectors3;
  16385. private _vectors4;
  16386. private _matrices;
  16387. private _matrixArrays;
  16388. private _matrices3x3;
  16389. private _matrices2x2;
  16390. private _vectors2Arrays;
  16391. private _vectors3Arrays;
  16392. private _vectors4Arrays;
  16393. private _cachedWorldViewMatrix;
  16394. private _cachedWorldViewProjectionMatrix;
  16395. private _renderId;
  16396. private _multiview;
  16397. private _cachedDefines;
  16398. /**
  16399. * Instantiate a new shader material.
  16400. * 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.
  16401. * This returned material effects how the mesh will look based on the code in the shaders.
  16402. * @see http://doc.babylonjs.com/how_to/shader_material
  16403. * @param name Define the name of the material in the scene
  16404. * @param scene Define the scene the material belongs to
  16405. * @param shaderPath Defines the route to the shader code in one of three ways:
  16406. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16407. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16408. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16409. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16410. * @param options Define the options used to create the shader
  16411. */
  16412. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16413. /**
  16414. * Gets the shader path used to define the shader code
  16415. * It can be modified to trigger a new compilation
  16416. */
  16417. get shaderPath(): any;
  16418. /**
  16419. * Sets the shader path used to define the shader code
  16420. * It can be modified to trigger a new compilation
  16421. */
  16422. set shaderPath(shaderPath: any);
  16423. /**
  16424. * Gets the options used to compile the shader.
  16425. * They can be modified to trigger a new compilation
  16426. */
  16427. get options(): IShaderMaterialOptions;
  16428. /**
  16429. * Gets the current class name of the material e.g. "ShaderMaterial"
  16430. * Mainly use in serialization.
  16431. * @returns the class name
  16432. */
  16433. getClassName(): string;
  16434. /**
  16435. * Specifies if the material will require alpha blending
  16436. * @returns a boolean specifying if alpha blending is needed
  16437. */
  16438. needAlphaBlending(): boolean;
  16439. /**
  16440. * Specifies if this material should be rendered in alpha test mode
  16441. * @returns a boolean specifying if an alpha test is needed.
  16442. */
  16443. needAlphaTesting(): boolean;
  16444. private _checkUniform;
  16445. /**
  16446. * Set a texture in the shader.
  16447. * @param name Define the name of the uniform samplers as defined in the shader
  16448. * @param texture Define the texture to bind to this sampler
  16449. * @return the material itself allowing "fluent" like uniform updates
  16450. */
  16451. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16452. /**
  16453. * Set a texture array in the shader.
  16454. * @param name Define the name of the uniform sampler array as defined in the shader
  16455. * @param textures Define the list of textures to bind to this sampler
  16456. * @return the material itself allowing "fluent" like uniform updates
  16457. */
  16458. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16459. /**
  16460. * Set a float in the shader.
  16461. * @param name Define the name of the uniform as defined in the shader
  16462. * @param value Define the value to give to the uniform
  16463. * @return the material itself allowing "fluent" like uniform updates
  16464. */
  16465. setFloat(name: string, value: number): ShaderMaterial;
  16466. /**
  16467. * Set a int in the shader.
  16468. * @param name Define the name of the uniform as defined in the shader
  16469. * @param value Define the value to give to the uniform
  16470. * @return the material itself allowing "fluent" like uniform updates
  16471. */
  16472. setInt(name: string, value: number): ShaderMaterial;
  16473. /**
  16474. * Set an array of floats in the shader.
  16475. * @param name Define the name of the uniform as defined in the shader
  16476. * @param value Define the value to give to the uniform
  16477. * @return the material itself allowing "fluent" like uniform updates
  16478. */
  16479. setFloats(name: string, value: number[]): ShaderMaterial;
  16480. /**
  16481. * Set a vec3 in the shader from a Color3.
  16482. * @param name Define the name of the uniform as defined in the shader
  16483. * @param value Define the value to give to the uniform
  16484. * @return the material itself allowing "fluent" like uniform updates
  16485. */
  16486. setColor3(name: string, value: Color3): ShaderMaterial;
  16487. /**
  16488. * Set a vec3 array in the shader from a Color3 array.
  16489. * @param name Define the name of the uniform as defined in the shader
  16490. * @param value Define the value to give to the uniform
  16491. * @return the material itself allowing "fluent" like uniform updates
  16492. */
  16493. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16494. /**
  16495. * Set a vec4 in the shader from a Color4.
  16496. * @param name Define the name of the uniform as defined in the shader
  16497. * @param value Define the value to give to the uniform
  16498. * @return the material itself allowing "fluent" like uniform updates
  16499. */
  16500. setColor4(name: string, value: Color4): ShaderMaterial;
  16501. /**
  16502. * Set a vec4 array in the shader from a Color4 array.
  16503. * @param name Define the name of the uniform as defined in the shader
  16504. * @param value Define the value to give to the uniform
  16505. * @return the material itself allowing "fluent" like uniform updates
  16506. */
  16507. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16508. /**
  16509. * Set a vec2 in the shader from a Vector2.
  16510. * @param name Define the name of the uniform as defined in the shader
  16511. * @param value Define the value to give to the uniform
  16512. * @return the material itself allowing "fluent" like uniform updates
  16513. */
  16514. setVector2(name: string, value: Vector2): ShaderMaterial;
  16515. /**
  16516. * Set a vec3 in the shader from a Vector3.
  16517. * @param name Define the name of the uniform as defined in the shader
  16518. * @param value Define the value to give to the uniform
  16519. * @return the material itself allowing "fluent" like uniform updates
  16520. */
  16521. setVector3(name: string, value: Vector3): ShaderMaterial;
  16522. /**
  16523. * Set a vec4 in the shader from a Vector4.
  16524. * @param name Define the name of the uniform as defined in the shader
  16525. * @param value Define the value to give to the uniform
  16526. * @return the material itself allowing "fluent" like uniform updates
  16527. */
  16528. setVector4(name: string, value: Vector4): ShaderMaterial;
  16529. /**
  16530. * Set a mat4 in the shader from a Matrix.
  16531. * @param name Define the name of the uniform as defined in the shader
  16532. * @param value Define the value to give to the uniform
  16533. * @return the material itself allowing "fluent" like uniform updates
  16534. */
  16535. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16536. /**
  16537. * Set a float32Array in the shader from a matrix array.
  16538. * @param name Define the name of the uniform as defined in the shader
  16539. * @param value Define the value to give to the uniform
  16540. * @return the material itself allowing "fluent" like uniform updates
  16541. */
  16542. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16543. /**
  16544. * Set a mat3 in the shader from a Float32Array.
  16545. * @param name Define the name of the uniform as defined in the shader
  16546. * @param value Define the value to give to the uniform
  16547. * @return the material itself allowing "fluent" like uniform updates
  16548. */
  16549. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16550. /**
  16551. * Set a mat2 in the shader from a Float32Array.
  16552. * @param name Define the name of the uniform as defined in the shader
  16553. * @param value Define the value to give to the uniform
  16554. * @return the material itself allowing "fluent" like uniform updates
  16555. */
  16556. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16557. /**
  16558. * Set a vec2 array in the shader from a number array.
  16559. * @param name Define the name of the uniform as defined in the shader
  16560. * @param value Define the value to give to the uniform
  16561. * @return the material itself allowing "fluent" like uniform updates
  16562. */
  16563. setArray2(name: string, value: number[]): ShaderMaterial;
  16564. /**
  16565. * Set a vec3 array in the shader from a number array.
  16566. * @param name Define the name of the uniform as defined in the shader
  16567. * @param value Define the value to give to the uniform
  16568. * @return the material itself allowing "fluent" like uniform updates
  16569. */
  16570. setArray3(name: string, value: number[]): ShaderMaterial;
  16571. /**
  16572. * Set a vec4 array in the shader from a number array.
  16573. * @param name Define the name of the uniform as defined in the shader
  16574. * @param value Define the value to give to the uniform
  16575. * @return the material itself allowing "fluent" like uniform updates
  16576. */
  16577. setArray4(name: string, value: number[]): ShaderMaterial;
  16578. private _checkCache;
  16579. /**
  16580. * Specifies that the submesh is ready to be used
  16581. * @param mesh defines the mesh to check
  16582. * @param subMesh defines which submesh to check
  16583. * @param useInstances specifies that instances should be used
  16584. * @returns a boolean indicating that the submesh is ready or not
  16585. */
  16586. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16587. /**
  16588. * Checks if the material is ready to render the requested mesh
  16589. * @param mesh Define the mesh to render
  16590. * @param useInstances Define whether or not the material is used with instances
  16591. * @returns true if ready, otherwise false
  16592. */
  16593. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16594. /**
  16595. * Binds the world matrix to the material
  16596. * @param world defines the world transformation matrix
  16597. * @param effectOverride - If provided, use this effect instead of internal effect
  16598. */
  16599. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16600. /**
  16601. * Binds the submesh to this material by preparing the effect and shader to draw
  16602. * @param world defines the world transformation matrix
  16603. * @param mesh defines the mesh containing the submesh
  16604. * @param subMesh defines the submesh to bind the material to
  16605. */
  16606. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16607. /**
  16608. * Binds the material to the mesh
  16609. * @param world defines the world transformation matrix
  16610. * @param mesh defines the mesh to bind the material to
  16611. * @param effectOverride - If provided, use this effect instead of internal effect
  16612. */
  16613. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16614. protected _afterBind(mesh?: Mesh): void;
  16615. /**
  16616. * Gets the active textures from the material
  16617. * @returns an array of textures
  16618. */
  16619. getActiveTextures(): BaseTexture[];
  16620. /**
  16621. * Specifies if the material uses a texture
  16622. * @param texture defines the texture to check against the material
  16623. * @returns a boolean specifying if the material uses the texture
  16624. */
  16625. hasTexture(texture: BaseTexture): boolean;
  16626. /**
  16627. * Makes a duplicate of the material, and gives it a new name
  16628. * @param name defines the new name for the duplicated material
  16629. * @returns the cloned material
  16630. */
  16631. clone(name: string): ShaderMaterial;
  16632. /**
  16633. * Disposes the material
  16634. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16635. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16636. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16637. */
  16638. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16639. /**
  16640. * Serializes this material in a JSON representation
  16641. * @returns the serialized material object
  16642. */
  16643. serialize(): any;
  16644. /**
  16645. * Creates a shader material from parsed shader material data
  16646. * @param source defines the JSON represnetation of the material
  16647. * @param scene defines the hosting scene
  16648. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16649. * @returns a new material
  16650. */
  16651. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16652. }
  16653. }
  16654. declare module BABYLON {
  16655. /** @hidden */
  16656. export var colorPixelShader: {
  16657. name: string;
  16658. shader: string;
  16659. };
  16660. }
  16661. declare module BABYLON {
  16662. /** @hidden */
  16663. export var colorVertexShader: {
  16664. name: string;
  16665. shader: string;
  16666. };
  16667. }
  16668. declare module BABYLON {
  16669. /**
  16670. * Line mesh
  16671. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16672. */
  16673. export class LinesMesh extends Mesh {
  16674. /**
  16675. * If vertex color should be applied to the mesh
  16676. */
  16677. readonly useVertexColor?: boolean | undefined;
  16678. /**
  16679. * If vertex alpha should be applied to the mesh
  16680. */
  16681. readonly useVertexAlpha?: boolean | undefined;
  16682. /**
  16683. * Color of the line (Default: White)
  16684. */
  16685. color: Color3;
  16686. /**
  16687. * Alpha of the line (Default: 1)
  16688. */
  16689. alpha: number;
  16690. /**
  16691. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16692. * This margin is expressed in world space coordinates, so its value may vary.
  16693. * Default value is 0.1
  16694. */
  16695. intersectionThreshold: number;
  16696. private _colorShader;
  16697. private color4;
  16698. /**
  16699. * Creates a new LinesMesh
  16700. * @param name defines the name
  16701. * @param scene defines the hosting scene
  16702. * @param parent defines the parent mesh if any
  16703. * @param source defines the optional source LinesMesh used to clone data from
  16704. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16705. * When false, achieved by calling a clone(), also passing False.
  16706. * This will make creation of children, recursive.
  16707. * @param useVertexColor defines if this LinesMesh supports vertex color
  16708. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16709. */
  16710. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16711. /**
  16712. * If vertex color should be applied to the mesh
  16713. */
  16714. useVertexColor?: boolean | undefined,
  16715. /**
  16716. * If vertex alpha should be applied to the mesh
  16717. */
  16718. useVertexAlpha?: boolean | undefined);
  16719. private _addClipPlaneDefine;
  16720. private _removeClipPlaneDefine;
  16721. isReady(): boolean;
  16722. /**
  16723. * Returns the string "LineMesh"
  16724. */
  16725. getClassName(): string;
  16726. /**
  16727. * @hidden
  16728. */
  16729. get material(): Material;
  16730. /**
  16731. * @hidden
  16732. */
  16733. set material(value: Material);
  16734. /**
  16735. * @hidden
  16736. */
  16737. get checkCollisions(): boolean;
  16738. /** @hidden */
  16739. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16740. /** @hidden */
  16741. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16742. /**
  16743. * Disposes of the line mesh
  16744. * @param doNotRecurse If children should be disposed
  16745. */
  16746. dispose(doNotRecurse?: boolean): void;
  16747. /**
  16748. * Returns a new LineMesh object cloned from the current one.
  16749. */
  16750. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16751. /**
  16752. * Creates a new InstancedLinesMesh object from the mesh model.
  16753. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16754. * @param name defines the name of the new instance
  16755. * @returns a new InstancedLinesMesh
  16756. */
  16757. createInstance(name: string): InstancedLinesMesh;
  16758. }
  16759. /**
  16760. * Creates an instance based on a source LinesMesh
  16761. */
  16762. export class InstancedLinesMesh extends InstancedMesh {
  16763. /**
  16764. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16765. * This margin is expressed in world space coordinates, so its value may vary.
  16766. * Initilized with the intersectionThreshold value of the source LinesMesh
  16767. */
  16768. intersectionThreshold: number;
  16769. constructor(name: string, source: LinesMesh);
  16770. /**
  16771. * Returns the string "InstancedLinesMesh".
  16772. */
  16773. getClassName(): string;
  16774. }
  16775. }
  16776. declare module BABYLON {
  16777. /** @hidden */
  16778. export var linePixelShader: {
  16779. name: string;
  16780. shader: string;
  16781. };
  16782. }
  16783. declare module BABYLON {
  16784. /** @hidden */
  16785. export var lineVertexShader: {
  16786. name: string;
  16787. shader: string;
  16788. };
  16789. }
  16790. declare module BABYLON {
  16791. interface AbstractMesh {
  16792. /**
  16793. * Gets the edgesRenderer associated with the mesh
  16794. */
  16795. edgesRenderer: Nullable<EdgesRenderer>;
  16796. }
  16797. interface LinesMesh {
  16798. /**
  16799. * Enables the edge rendering mode on the mesh.
  16800. * This mode makes the mesh edges visible
  16801. * @param epsilon defines the maximal distance between two angles to detect a face
  16802. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16803. * @returns the currentAbstractMesh
  16804. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16805. */
  16806. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16807. }
  16808. interface InstancedLinesMesh {
  16809. /**
  16810. * Enables the edge rendering mode on the mesh.
  16811. * This mode makes the mesh edges visible
  16812. * @param epsilon defines the maximal distance between two angles to detect a face
  16813. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16814. * @returns the current InstancedLinesMesh
  16815. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16816. */
  16817. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16818. }
  16819. /**
  16820. * Defines the minimum contract an Edges renderer should follow.
  16821. */
  16822. export interface IEdgesRenderer extends IDisposable {
  16823. /**
  16824. * Gets or sets a boolean indicating if the edgesRenderer is active
  16825. */
  16826. isEnabled: boolean;
  16827. /**
  16828. * Renders the edges of the attached mesh,
  16829. */
  16830. render(): void;
  16831. /**
  16832. * Checks wether or not the edges renderer is ready to render.
  16833. * @return true if ready, otherwise false.
  16834. */
  16835. isReady(): boolean;
  16836. }
  16837. /**
  16838. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16839. */
  16840. export class EdgesRenderer implements IEdgesRenderer {
  16841. /**
  16842. * Define the size of the edges with an orthographic camera
  16843. */
  16844. edgesWidthScalerForOrthographic: number;
  16845. /**
  16846. * Define the size of the edges with a perspective camera
  16847. */
  16848. edgesWidthScalerForPerspective: number;
  16849. protected _source: AbstractMesh;
  16850. protected _linesPositions: number[];
  16851. protected _linesNormals: number[];
  16852. protected _linesIndices: number[];
  16853. protected _epsilon: number;
  16854. protected _indicesCount: number;
  16855. protected _lineShader: ShaderMaterial;
  16856. protected _ib: DataBuffer;
  16857. protected _buffers: {
  16858. [key: string]: Nullable<VertexBuffer>;
  16859. };
  16860. protected _checkVerticesInsteadOfIndices: boolean;
  16861. private _meshRebuildObserver;
  16862. private _meshDisposeObserver;
  16863. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16864. isEnabled: boolean;
  16865. /**
  16866. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16867. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16868. * @param source Mesh used to create edges
  16869. * @param epsilon sum of angles in adjacency to check for edge
  16870. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16871. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16872. */
  16873. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16874. protected _prepareRessources(): void;
  16875. /** @hidden */
  16876. _rebuild(): void;
  16877. /**
  16878. * Releases the required resources for the edges renderer
  16879. */
  16880. dispose(): void;
  16881. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16882. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16883. /**
  16884. * Checks if the pair of p0 and p1 is en edge
  16885. * @param faceIndex
  16886. * @param edge
  16887. * @param faceNormals
  16888. * @param p0
  16889. * @param p1
  16890. * @private
  16891. */
  16892. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16893. /**
  16894. * push line into the position, normal and index buffer
  16895. * @protected
  16896. */
  16897. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16898. /**
  16899. * Generates lines edges from adjacencjes
  16900. * @private
  16901. */
  16902. _generateEdgesLines(): void;
  16903. /**
  16904. * Checks wether or not the edges renderer is ready to render.
  16905. * @return true if ready, otherwise false.
  16906. */
  16907. isReady(): boolean;
  16908. /**
  16909. * Renders the edges of the attached mesh,
  16910. */
  16911. render(): void;
  16912. }
  16913. /**
  16914. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16915. */
  16916. export class LineEdgesRenderer extends EdgesRenderer {
  16917. /**
  16918. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16919. * @param source LineMesh used to generate edges
  16920. * @param epsilon not important (specified angle for edge detection)
  16921. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16922. */
  16923. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16924. /**
  16925. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16926. */
  16927. _generateEdgesLines(): void;
  16928. }
  16929. }
  16930. declare module BABYLON {
  16931. /**
  16932. * This represents the object necessary to create a rendering group.
  16933. * This is exclusively used and created by the rendering manager.
  16934. * To modify the behavior, you use the available helpers in your scene or meshes.
  16935. * @hidden
  16936. */
  16937. export class RenderingGroup {
  16938. index: number;
  16939. private static _zeroVector;
  16940. private _scene;
  16941. private _opaqueSubMeshes;
  16942. private _transparentSubMeshes;
  16943. private _alphaTestSubMeshes;
  16944. private _depthOnlySubMeshes;
  16945. private _particleSystems;
  16946. private _spriteManagers;
  16947. private _opaqueSortCompareFn;
  16948. private _alphaTestSortCompareFn;
  16949. private _transparentSortCompareFn;
  16950. private _renderOpaque;
  16951. private _renderAlphaTest;
  16952. private _renderTransparent;
  16953. /** @hidden */
  16954. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  16955. onBeforeTransparentRendering: () => void;
  16956. /**
  16957. * Set the opaque sort comparison function.
  16958. * If null the sub meshes will be render in the order they were created
  16959. */
  16960. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16961. /**
  16962. * Set the alpha test sort comparison function.
  16963. * If null the sub meshes will be render in the order they were created
  16964. */
  16965. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16966. /**
  16967. * Set the transparent sort comparison function.
  16968. * If null the sub meshes will be render in the order they were created
  16969. */
  16970. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16971. /**
  16972. * Creates a new rendering group.
  16973. * @param index The rendering group index
  16974. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16975. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16976. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16977. */
  16978. 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>);
  16979. /**
  16980. * Render all the sub meshes contained in the group.
  16981. * @param customRenderFunction Used to override the default render behaviour of the group.
  16982. * @returns true if rendered some submeshes.
  16983. */
  16984. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16985. /**
  16986. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16987. * @param subMeshes The submeshes to render
  16988. */
  16989. private renderOpaqueSorted;
  16990. /**
  16991. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16992. * @param subMeshes The submeshes to render
  16993. */
  16994. private renderAlphaTestSorted;
  16995. /**
  16996. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16997. * @param subMeshes The submeshes to render
  16998. */
  16999. private renderTransparentSorted;
  17000. /**
  17001. * Renders the submeshes in a specified order.
  17002. * @param subMeshes The submeshes to sort before render
  17003. * @param sortCompareFn The comparison function use to sort
  17004. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17005. * @param transparent Specifies to activate blending if true
  17006. */
  17007. private static renderSorted;
  17008. /**
  17009. * Renders the submeshes in the order they were dispatched (no sort applied).
  17010. * @param subMeshes The submeshes to render
  17011. */
  17012. private static renderUnsorted;
  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 if in the same alpha index.
  17016. *
  17017. * @param a The first submesh
  17018. * @param b The second submesh
  17019. * @returns The result of the comparison
  17020. */
  17021. static defaultTransparentSortCompare(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 back to front.
  17025. *
  17026. * @param a The first submesh
  17027. * @param b The second submesh
  17028. * @returns The result of the comparison
  17029. */
  17030. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17031. /**
  17032. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17033. * are rendered front to back (prevent overdraw).
  17034. *
  17035. * @param a The first submesh
  17036. * @param b The second submesh
  17037. * @returns The result of the comparison
  17038. */
  17039. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17040. /**
  17041. * Resets the different lists of submeshes to prepare a new frame.
  17042. */
  17043. prepare(): void;
  17044. dispose(): void;
  17045. /**
  17046. * Inserts the submesh in its correct queue depending on its material.
  17047. * @param subMesh The submesh to dispatch
  17048. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17049. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17050. */
  17051. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17052. dispatchSprites(spriteManager: ISpriteManager): void;
  17053. dispatchParticles(particleSystem: IParticleSystem): void;
  17054. private _renderParticles;
  17055. private _renderSprites;
  17056. }
  17057. }
  17058. declare module BABYLON {
  17059. /**
  17060. * Interface describing the different options available in the rendering manager
  17061. * regarding Auto Clear between groups.
  17062. */
  17063. export interface IRenderingManagerAutoClearSetup {
  17064. /**
  17065. * Defines whether or not autoclear is enable.
  17066. */
  17067. autoClear: boolean;
  17068. /**
  17069. * Defines whether or not to autoclear the depth buffer.
  17070. */
  17071. depth: boolean;
  17072. /**
  17073. * Defines whether or not to autoclear the stencil buffer.
  17074. */
  17075. stencil: boolean;
  17076. }
  17077. /**
  17078. * This class is used by the onRenderingGroupObservable
  17079. */
  17080. export class RenderingGroupInfo {
  17081. /**
  17082. * The Scene that being rendered
  17083. */
  17084. scene: Scene;
  17085. /**
  17086. * The camera currently used for the rendering pass
  17087. */
  17088. camera: Nullable<Camera>;
  17089. /**
  17090. * The ID of the renderingGroup being processed
  17091. */
  17092. renderingGroupId: number;
  17093. }
  17094. /**
  17095. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17096. * It is enable to manage the different groups as well as the different necessary sort functions.
  17097. * This should not be used directly aside of the few static configurations
  17098. */
  17099. export class RenderingManager {
  17100. /**
  17101. * The max id used for rendering groups (not included)
  17102. */
  17103. static MAX_RENDERINGGROUPS: number;
  17104. /**
  17105. * The min id used for rendering groups (included)
  17106. */
  17107. static MIN_RENDERINGGROUPS: number;
  17108. /**
  17109. * Used to globally prevent autoclearing scenes.
  17110. */
  17111. static AUTOCLEAR: boolean;
  17112. /**
  17113. * @hidden
  17114. */
  17115. _useSceneAutoClearSetup: boolean;
  17116. private _scene;
  17117. private _renderingGroups;
  17118. private _depthStencilBufferAlreadyCleaned;
  17119. private _autoClearDepthStencil;
  17120. private _customOpaqueSortCompareFn;
  17121. private _customAlphaTestSortCompareFn;
  17122. private _customTransparentSortCompareFn;
  17123. private _renderingGroupInfo;
  17124. /**
  17125. * Instantiates a new rendering group for a particular scene
  17126. * @param scene Defines the scene the groups belongs to
  17127. */
  17128. constructor(scene: Scene);
  17129. private _clearDepthStencilBuffer;
  17130. /**
  17131. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17132. * @hidden
  17133. */
  17134. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17135. /**
  17136. * Resets the different information of the group to prepare a new frame
  17137. * @hidden
  17138. */
  17139. reset(): void;
  17140. /**
  17141. * Dispose and release the group and its associated resources.
  17142. * @hidden
  17143. */
  17144. dispose(): void;
  17145. /**
  17146. * Clear the info related to rendering groups preventing retention points during dispose.
  17147. */
  17148. freeRenderingGroups(): void;
  17149. private _prepareRenderingGroup;
  17150. /**
  17151. * Add a sprite manager to the rendering manager in order to render it this frame.
  17152. * @param spriteManager Define the sprite manager to render
  17153. */
  17154. dispatchSprites(spriteManager: ISpriteManager): void;
  17155. /**
  17156. * Add a particle system to the rendering manager in order to render it this frame.
  17157. * @param particleSystem Define the particle system to render
  17158. */
  17159. dispatchParticles(particleSystem: IParticleSystem): void;
  17160. /**
  17161. * Add a submesh to the manager in order to render it this frame
  17162. * @param subMesh The submesh to dispatch
  17163. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17164. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17165. */
  17166. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17167. /**
  17168. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17169. * This allowed control for front to back rendering or reversly depending of the special needs.
  17170. *
  17171. * @param renderingGroupId The rendering group id corresponding to its index
  17172. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17173. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17174. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17175. */
  17176. 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;
  17177. /**
  17178. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17179. *
  17180. * @param renderingGroupId The rendering group id corresponding to its index
  17181. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17182. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17183. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17184. */
  17185. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17186. /**
  17187. * Gets the current auto clear configuration for one rendering group of the rendering
  17188. * manager.
  17189. * @param index the rendering group index to get the information for
  17190. * @returns The auto clear setup for the requested rendering group
  17191. */
  17192. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17193. }
  17194. }
  17195. declare module BABYLON {
  17196. /**
  17197. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17198. */
  17199. export interface ICustomShaderOptions {
  17200. /**
  17201. * Gets or sets the custom shader name to use
  17202. */
  17203. shaderName: string;
  17204. /**
  17205. * The list of attribute names used in the shader
  17206. */
  17207. attributes?: string[];
  17208. /**
  17209. * The list of unifrom names used in the shader
  17210. */
  17211. uniforms?: string[];
  17212. /**
  17213. * The list of sampler names used in the shader
  17214. */
  17215. samplers?: string[];
  17216. /**
  17217. * The list of defines used in the shader
  17218. */
  17219. defines?: string[];
  17220. }
  17221. /**
  17222. * Interface to implement to create a shadow generator compatible with BJS.
  17223. */
  17224. export interface IShadowGenerator {
  17225. /**
  17226. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17227. * @returns The render target texture if present otherwise, null
  17228. */
  17229. getShadowMap(): Nullable<RenderTargetTexture>;
  17230. /**
  17231. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17232. * @param subMesh The submesh we want to render in the shadow map
  17233. * @param useInstances Defines wether will draw in the map using instances
  17234. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17235. * @returns true if ready otherwise, false
  17236. */
  17237. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17238. /**
  17239. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17240. * @param defines Defines of the material we want to update
  17241. * @param lightIndex Index of the light in the enabled light list of the material
  17242. */
  17243. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17244. /**
  17245. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17246. * defined in the generator but impacting the effect).
  17247. * It implies the unifroms available on the materials are the standard BJS ones.
  17248. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17249. * @param effect The effect we are binfing the information for
  17250. */
  17251. bindShadowLight(lightIndex: string, effect: Effect): void;
  17252. /**
  17253. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17254. * (eq to shadow prjection matrix * light transform matrix)
  17255. * @returns The transform matrix used to create the shadow map
  17256. */
  17257. getTransformMatrix(): Matrix;
  17258. /**
  17259. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17260. * Cube and 2D textures for instance.
  17261. */
  17262. recreateShadowMap(): void;
  17263. /**
  17264. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17265. * @param onCompiled Callback triggered at the and of the effects compilation
  17266. * @param options Sets of optional options forcing the compilation with different modes
  17267. */
  17268. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17269. useInstances: boolean;
  17270. }>): void;
  17271. /**
  17272. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17273. * @param options Sets of optional options forcing the compilation with different modes
  17274. * @returns A promise that resolves when the compilation completes
  17275. */
  17276. forceCompilationAsync(options?: Partial<{
  17277. useInstances: boolean;
  17278. }>): Promise<void>;
  17279. /**
  17280. * Serializes the shadow generator setup to a json object.
  17281. * @returns The serialized JSON object
  17282. */
  17283. serialize(): any;
  17284. /**
  17285. * Disposes the Shadow map and related Textures and effects.
  17286. */
  17287. dispose(): void;
  17288. }
  17289. /**
  17290. * Default implementation IShadowGenerator.
  17291. * This is the main object responsible of generating shadows in the framework.
  17292. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17293. */
  17294. export class ShadowGenerator implements IShadowGenerator {
  17295. /**
  17296. * Name of the shadow generator class
  17297. */
  17298. static CLASSNAME: string;
  17299. /**
  17300. * Shadow generator mode None: no filtering applied.
  17301. */
  17302. static readonly FILTER_NONE: number;
  17303. /**
  17304. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17305. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17306. */
  17307. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17308. /**
  17309. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17310. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17311. */
  17312. static readonly FILTER_POISSONSAMPLING: number;
  17313. /**
  17314. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17315. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17316. */
  17317. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17318. /**
  17319. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17320. * edge artifacts on steep falloff.
  17321. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17322. */
  17323. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17324. /**
  17325. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17326. * edge artifacts on steep falloff.
  17327. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17328. */
  17329. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17330. /**
  17331. * Shadow generator mode PCF: Percentage Closer Filtering
  17332. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17333. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17334. */
  17335. static readonly FILTER_PCF: number;
  17336. /**
  17337. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17338. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17339. * Contact Hardening
  17340. */
  17341. static readonly FILTER_PCSS: number;
  17342. /**
  17343. * Reserved for PCF and PCSS
  17344. * Highest Quality.
  17345. *
  17346. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17347. *
  17348. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17349. */
  17350. static readonly QUALITY_HIGH: number;
  17351. /**
  17352. * Reserved for PCF and PCSS
  17353. * Good tradeoff for quality/perf cross devices
  17354. *
  17355. * Execute PCF on a 3*3 kernel.
  17356. *
  17357. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17358. */
  17359. static readonly QUALITY_MEDIUM: number;
  17360. /**
  17361. * Reserved for PCF and PCSS
  17362. * The lowest quality but the fastest.
  17363. *
  17364. * Execute PCF on a 1*1 kernel.
  17365. *
  17366. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17367. */
  17368. static readonly QUALITY_LOW: number;
  17369. /** Gets or sets the custom shader name to use */
  17370. customShaderOptions: ICustomShaderOptions;
  17371. /**
  17372. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17373. */
  17374. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17375. /**
  17376. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17377. */
  17378. onAfterShadowMapRenderObservable: Observable<Effect>;
  17379. /**
  17380. * Observable triggered before a mesh is rendered in the shadow map.
  17381. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17382. */
  17383. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17384. /**
  17385. * Observable triggered after a mesh is rendered in the shadow map.
  17386. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17387. */
  17388. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17389. protected _bias: number;
  17390. /**
  17391. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17392. */
  17393. get bias(): number;
  17394. /**
  17395. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17396. */
  17397. set bias(bias: number);
  17398. protected _normalBias: number;
  17399. /**
  17400. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17401. */
  17402. get normalBias(): number;
  17403. /**
  17404. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17405. */
  17406. set normalBias(normalBias: number);
  17407. protected _blurBoxOffset: number;
  17408. /**
  17409. * Gets the blur box offset: offset applied during the blur pass.
  17410. * Only useful if useKernelBlur = false
  17411. */
  17412. get blurBoxOffset(): number;
  17413. /**
  17414. * Sets the blur box offset: offset applied during the blur pass.
  17415. * Only useful if useKernelBlur = false
  17416. */
  17417. set blurBoxOffset(value: number);
  17418. protected _blurScale: number;
  17419. /**
  17420. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17421. * 2 means half of the size.
  17422. */
  17423. get blurScale(): number;
  17424. /**
  17425. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17426. * 2 means half of the size.
  17427. */
  17428. set blurScale(value: number);
  17429. protected _blurKernel: number;
  17430. /**
  17431. * Gets the blur kernel: kernel size of the blur pass.
  17432. * Only useful if useKernelBlur = true
  17433. */
  17434. get blurKernel(): number;
  17435. /**
  17436. * Sets the blur kernel: kernel size of the blur pass.
  17437. * Only useful if useKernelBlur = true
  17438. */
  17439. set blurKernel(value: number);
  17440. protected _useKernelBlur: boolean;
  17441. /**
  17442. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17443. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17444. */
  17445. get useKernelBlur(): boolean;
  17446. /**
  17447. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17448. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17449. */
  17450. set useKernelBlur(value: boolean);
  17451. protected _depthScale: number;
  17452. /**
  17453. * Gets the depth scale used in ESM mode.
  17454. */
  17455. get depthScale(): number;
  17456. /**
  17457. * Sets the depth scale used in ESM mode.
  17458. * This can override the scale stored on the light.
  17459. */
  17460. set depthScale(value: number);
  17461. protected _validateFilter(filter: number): number;
  17462. protected _filter: number;
  17463. /**
  17464. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17465. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17466. */
  17467. get filter(): number;
  17468. /**
  17469. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17470. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17471. */
  17472. set filter(value: number);
  17473. /**
  17474. * Gets if the current filter is set to Poisson Sampling.
  17475. */
  17476. get usePoissonSampling(): boolean;
  17477. /**
  17478. * Sets the current filter to Poisson Sampling.
  17479. */
  17480. set usePoissonSampling(value: boolean);
  17481. /**
  17482. * Gets if the current filter is set to ESM.
  17483. */
  17484. get useExponentialShadowMap(): boolean;
  17485. /**
  17486. * Sets the current filter is to ESM.
  17487. */
  17488. set useExponentialShadowMap(value: boolean);
  17489. /**
  17490. * Gets if the current filter is set to filtered ESM.
  17491. */
  17492. get useBlurExponentialShadowMap(): boolean;
  17493. /**
  17494. * Gets if the current filter is set to filtered ESM.
  17495. */
  17496. set useBlurExponentialShadowMap(value: boolean);
  17497. /**
  17498. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17499. * exponential to prevent steep falloff artifacts).
  17500. */
  17501. get useCloseExponentialShadowMap(): boolean;
  17502. /**
  17503. * Sets the current filter to "close ESM" (using the inverse of the
  17504. * exponential to prevent steep falloff artifacts).
  17505. */
  17506. set useCloseExponentialShadowMap(value: boolean);
  17507. /**
  17508. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17509. * exponential to prevent steep falloff artifacts).
  17510. */
  17511. get useBlurCloseExponentialShadowMap(): boolean;
  17512. /**
  17513. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17514. * exponential to prevent steep falloff artifacts).
  17515. */
  17516. set useBlurCloseExponentialShadowMap(value: boolean);
  17517. /**
  17518. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17519. */
  17520. get usePercentageCloserFiltering(): boolean;
  17521. /**
  17522. * Sets the current filter to "PCF" (percentage closer filtering).
  17523. */
  17524. set usePercentageCloserFiltering(value: boolean);
  17525. protected _filteringQuality: number;
  17526. /**
  17527. * Gets the PCF or PCSS Quality.
  17528. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17529. */
  17530. get filteringQuality(): number;
  17531. /**
  17532. * Sets the PCF or PCSS Quality.
  17533. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17534. */
  17535. set filteringQuality(filteringQuality: number);
  17536. /**
  17537. * Gets if the current filter is set to "PCSS" (contact hardening).
  17538. */
  17539. get useContactHardeningShadow(): boolean;
  17540. /**
  17541. * Sets the current filter to "PCSS" (contact hardening).
  17542. */
  17543. set useContactHardeningShadow(value: boolean);
  17544. protected _contactHardeningLightSizeUVRatio: number;
  17545. /**
  17546. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17547. * Using a ratio helps keeping shape stability independently of the map size.
  17548. *
  17549. * It does not account for the light projection as it was having too much
  17550. * instability during the light setup or during light position changes.
  17551. *
  17552. * Only valid if useContactHardeningShadow is true.
  17553. */
  17554. get contactHardeningLightSizeUVRatio(): number;
  17555. /**
  17556. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17557. * Using a ratio helps keeping shape stability independently of the map size.
  17558. *
  17559. * It does not account for the light projection as it was having too much
  17560. * instability during the light setup or during light position changes.
  17561. *
  17562. * Only valid if useContactHardeningShadow is true.
  17563. */
  17564. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17565. protected _darkness: number;
  17566. /** Gets or sets the actual darkness of a shadow */
  17567. get darkness(): number;
  17568. set darkness(value: number);
  17569. /**
  17570. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17571. * 0 means strongest and 1 would means no shadow.
  17572. * @returns the darkness.
  17573. */
  17574. getDarkness(): number;
  17575. /**
  17576. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17577. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17578. * @returns the shadow generator allowing fluent coding.
  17579. */
  17580. setDarkness(darkness: number): ShadowGenerator;
  17581. protected _transparencyShadow: boolean;
  17582. /** Gets or sets the ability to have transparent shadow */
  17583. get transparencyShadow(): boolean;
  17584. set transparencyShadow(value: boolean);
  17585. /**
  17586. * Sets the ability to have transparent shadow (boolean).
  17587. * @param transparent True if transparent else False
  17588. * @returns the shadow generator allowing fluent coding
  17589. */
  17590. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17591. /**
  17592. * Enables or disables shadows with varying strength based on the transparency
  17593. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17594. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17595. * mesh.visibility * alphaTexture.a
  17596. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17597. */
  17598. enableSoftTransparentShadow: boolean;
  17599. protected _shadowMap: Nullable<RenderTargetTexture>;
  17600. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17601. /**
  17602. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17603. * @returns The render target texture if present otherwise, null
  17604. */
  17605. getShadowMap(): Nullable<RenderTargetTexture>;
  17606. /**
  17607. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17608. * @returns The render target texture if the shadow map is present otherwise, null
  17609. */
  17610. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17611. /**
  17612. * Gets the class name of that object
  17613. * @returns "ShadowGenerator"
  17614. */
  17615. getClassName(): string;
  17616. /**
  17617. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17618. * @param mesh Mesh to add
  17619. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17620. * @returns the Shadow Generator itself
  17621. */
  17622. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17623. /**
  17624. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17625. * @param mesh Mesh to remove
  17626. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17627. * @returns the Shadow Generator itself
  17628. */
  17629. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17630. /**
  17631. * Controls the extent to which the shadows fade out at the edge of the frustum
  17632. */
  17633. frustumEdgeFalloff: number;
  17634. protected _light: IShadowLight;
  17635. /**
  17636. * Returns the associated light object.
  17637. * @returns the light generating the shadow
  17638. */
  17639. getLight(): IShadowLight;
  17640. /**
  17641. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17642. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17643. * It might on the other hand introduce peter panning.
  17644. */
  17645. forceBackFacesOnly: boolean;
  17646. protected _scene: Scene;
  17647. protected _lightDirection: Vector3;
  17648. protected _effect: Effect;
  17649. protected _viewMatrix: Matrix;
  17650. protected _projectionMatrix: Matrix;
  17651. protected _transformMatrix: Matrix;
  17652. protected _cachedPosition: Vector3;
  17653. protected _cachedDirection: Vector3;
  17654. protected _cachedDefines: string;
  17655. protected _currentRenderID: number;
  17656. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17657. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17658. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17659. protected _blurPostProcesses: PostProcess[];
  17660. protected _mapSize: number;
  17661. protected _currentFaceIndex: number;
  17662. protected _currentFaceIndexCache: number;
  17663. protected _textureType: number;
  17664. protected _defaultTextureMatrix: Matrix;
  17665. protected _storedUniqueId: Nullable<number>;
  17666. /** @hidden */
  17667. static _SceneComponentInitialization: (scene: Scene) => void;
  17668. /**
  17669. * Creates a ShadowGenerator object.
  17670. * A ShadowGenerator is the required tool to use the shadows.
  17671. * Each light casting shadows needs to use its own ShadowGenerator.
  17672. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17673. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17674. * @param light The light object generating the shadows.
  17675. * @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.
  17676. */
  17677. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17678. protected _initializeGenerator(): void;
  17679. protected _createTargetRenderTexture(): void;
  17680. protected _initializeShadowMap(): void;
  17681. protected _initializeBlurRTTAndPostProcesses(): void;
  17682. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17683. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17684. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17685. protected _applyFilterValues(): void;
  17686. /**
  17687. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17688. * @param onCompiled Callback triggered at the and of the effects compilation
  17689. * @param options Sets of optional options forcing the compilation with different modes
  17690. */
  17691. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17692. useInstances: boolean;
  17693. }>): void;
  17694. /**
  17695. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17696. * @param options Sets of optional options forcing the compilation with different modes
  17697. * @returns A promise that resolves when the compilation completes
  17698. */
  17699. forceCompilationAsync(options?: Partial<{
  17700. useInstances: boolean;
  17701. }>): Promise<void>;
  17702. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17703. private _prepareShadowDefines;
  17704. /**
  17705. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17706. * @param subMesh The submesh we want to render in the shadow map
  17707. * @param useInstances Defines wether will draw in the map using instances
  17708. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17709. * @returns true if ready otherwise, false
  17710. */
  17711. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17712. /**
  17713. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17714. * @param defines Defines of the material we want to update
  17715. * @param lightIndex Index of the light in the enabled light list of the material
  17716. */
  17717. prepareDefines(defines: any, lightIndex: number): void;
  17718. /**
  17719. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17720. * defined in the generator but impacting the effect).
  17721. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17722. * @param effect The effect we are binfing the information for
  17723. */
  17724. bindShadowLight(lightIndex: string, effect: Effect): void;
  17725. /**
  17726. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17727. * (eq to shadow prjection matrix * light transform matrix)
  17728. * @returns The transform matrix used to create the shadow map
  17729. */
  17730. getTransformMatrix(): Matrix;
  17731. /**
  17732. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17733. * Cube and 2D textures for instance.
  17734. */
  17735. recreateShadowMap(): void;
  17736. protected _disposeBlurPostProcesses(): void;
  17737. protected _disposeRTTandPostProcesses(): void;
  17738. /**
  17739. * Disposes the ShadowGenerator.
  17740. * Returns nothing.
  17741. */
  17742. dispose(): void;
  17743. /**
  17744. * Serializes the shadow generator setup to a json object.
  17745. * @returns The serialized JSON object
  17746. */
  17747. serialize(): any;
  17748. /**
  17749. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17750. * @param parsedShadowGenerator The JSON object to parse
  17751. * @param scene The scene to create the shadow map for
  17752. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17753. * @returns The parsed shadow generator
  17754. */
  17755. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17756. }
  17757. }
  17758. declare module BABYLON {
  17759. /**
  17760. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17761. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17762. * 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.
  17763. */
  17764. export abstract class Light extends Node {
  17765. /**
  17766. * Falloff Default: light is falling off following the material specification:
  17767. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17768. */
  17769. static readonly FALLOFF_DEFAULT: number;
  17770. /**
  17771. * Falloff Physical: light is falling off following the inverse squared distance law.
  17772. */
  17773. static readonly FALLOFF_PHYSICAL: number;
  17774. /**
  17775. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17776. * to enhance interoperability with other engines.
  17777. */
  17778. static readonly FALLOFF_GLTF: number;
  17779. /**
  17780. * Falloff Standard: light is falling off like in the standard material
  17781. * to enhance interoperability with other materials.
  17782. */
  17783. static readonly FALLOFF_STANDARD: number;
  17784. /**
  17785. * If every light affecting the material is in this lightmapMode,
  17786. * material.lightmapTexture adds or multiplies
  17787. * (depends on material.useLightmapAsShadowmap)
  17788. * after every other light calculations.
  17789. */
  17790. static readonly LIGHTMAP_DEFAULT: number;
  17791. /**
  17792. * material.lightmapTexture as only diffuse lighting from this light
  17793. * adds only specular lighting from this light
  17794. * adds dynamic shadows
  17795. */
  17796. static readonly LIGHTMAP_SPECULAR: number;
  17797. /**
  17798. * material.lightmapTexture as only lighting
  17799. * no light calculation from this light
  17800. * only adds dynamic shadows from this light
  17801. */
  17802. static readonly LIGHTMAP_SHADOWSONLY: number;
  17803. /**
  17804. * Each light type uses the default quantity according to its type:
  17805. * point/spot lights use luminous intensity
  17806. * directional lights use illuminance
  17807. */
  17808. static readonly INTENSITYMODE_AUTOMATIC: number;
  17809. /**
  17810. * lumen (lm)
  17811. */
  17812. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17813. /**
  17814. * candela (lm/sr)
  17815. */
  17816. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17817. /**
  17818. * lux (lm/m^2)
  17819. */
  17820. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17821. /**
  17822. * nit (cd/m^2)
  17823. */
  17824. static readonly INTENSITYMODE_LUMINANCE: number;
  17825. /**
  17826. * Light type const id of the point light.
  17827. */
  17828. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17829. /**
  17830. * Light type const id of the directional light.
  17831. */
  17832. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17833. /**
  17834. * Light type const id of the spot light.
  17835. */
  17836. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17837. /**
  17838. * Light type const id of the hemispheric light.
  17839. */
  17840. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17841. /**
  17842. * Diffuse gives the basic color to an object.
  17843. */
  17844. diffuse: Color3;
  17845. /**
  17846. * Specular produces a highlight color on an object.
  17847. * Note: This is note affecting PBR materials.
  17848. */
  17849. specular: Color3;
  17850. /**
  17851. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17852. * falling off base on range or angle.
  17853. * This can be set to any values in Light.FALLOFF_x.
  17854. *
  17855. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17856. * other types of materials.
  17857. */
  17858. falloffType: number;
  17859. /**
  17860. * Strength of the light.
  17861. * Note: By default it is define in the framework own unit.
  17862. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17863. */
  17864. intensity: number;
  17865. private _range;
  17866. protected _inverseSquaredRange: number;
  17867. /**
  17868. * Defines how far from the source the light is impacting in scene units.
  17869. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17870. */
  17871. get range(): number;
  17872. /**
  17873. * Defines how far from the source the light is impacting in scene units.
  17874. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17875. */
  17876. set range(value: number);
  17877. /**
  17878. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17879. * of light.
  17880. */
  17881. private _photometricScale;
  17882. private _intensityMode;
  17883. /**
  17884. * Gets the photometric scale used to interpret the intensity.
  17885. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17886. */
  17887. get intensityMode(): number;
  17888. /**
  17889. * Sets the photometric scale used to interpret the intensity.
  17890. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17891. */
  17892. set intensityMode(value: number);
  17893. private _radius;
  17894. /**
  17895. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17896. */
  17897. get radius(): number;
  17898. /**
  17899. * sets the light radius used by PBR Materials to simulate soft area lights.
  17900. */
  17901. set radius(value: number);
  17902. private _renderPriority;
  17903. /**
  17904. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17905. * exceeding the number allowed of the materials.
  17906. */
  17907. renderPriority: number;
  17908. private _shadowEnabled;
  17909. /**
  17910. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17911. * the current shadow generator.
  17912. */
  17913. get shadowEnabled(): boolean;
  17914. /**
  17915. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17916. * the current shadow generator.
  17917. */
  17918. set shadowEnabled(value: boolean);
  17919. private _includedOnlyMeshes;
  17920. /**
  17921. * Gets the only meshes impacted by this light.
  17922. */
  17923. get includedOnlyMeshes(): AbstractMesh[];
  17924. /**
  17925. * Sets the only meshes impacted by this light.
  17926. */
  17927. set includedOnlyMeshes(value: AbstractMesh[]);
  17928. private _excludedMeshes;
  17929. /**
  17930. * Gets the meshes not impacted by this light.
  17931. */
  17932. get excludedMeshes(): AbstractMesh[];
  17933. /**
  17934. * Sets the meshes not impacted by this light.
  17935. */
  17936. set excludedMeshes(value: AbstractMesh[]);
  17937. private _excludeWithLayerMask;
  17938. /**
  17939. * Gets the layer id use to find what meshes are not impacted by the light.
  17940. * Inactive if 0
  17941. */
  17942. get excludeWithLayerMask(): number;
  17943. /**
  17944. * Sets the layer id use to find what meshes are not impacted by the light.
  17945. * Inactive if 0
  17946. */
  17947. set excludeWithLayerMask(value: number);
  17948. private _includeOnlyWithLayerMask;
  17949. /**
  17950. * Gets the layer id use to find what meshes are impacted by the light.
  17951. * Inactive if 0
  17952. */
  17953. get includeOnlyWithLayerMask(): number;
  17954. /**
  17955. * Sets the layer id use to find what meshes are impacted by the light.
  17956. * Inactive if 0
  17957. */
  17958. set includeOnlyWithLayerMask(value: number);
  17959. private _lightmapMode;
  17960. /**
  17961. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17962. */
  17963. get lightmapMode(): number;
  17964. /**
  17965. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17966. */
  17967. set lightmapMode(value: number);
  17968. /**
  17969. * Shadow generator associted to the light.
  17970. * @hidden Internal use only.
  17971. */
  17972. _shadowGenerator: Nullable<IShadowGenerator>;
  17973. /**
  17974. * @hidden Internal use only.
  17975. */
  17976. _excludedMeshesIds: string[];
  17977. /**
  17978. * @hidden Internal use only.
  17979. */
  17980. _includedOnlyMeshesIds: string[];
  17981. /**
  17982. * The current light unifom buffer.
  17983. * @hidden Internal use only.
  17984. */
  17985. _uniformBuffer: UniformBuffer;
  17986. /** @hidden */
  17987. _renderId: number;
  17988. /**
  17989. * Creates a Light object in the scene.
  17990. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17991. * @param name The firendly name of the light
  17992. * @param scene The scene the light belongs too
  17993. */
  17994. constructor(name: string, scene: Scene);
  17995. protected abstract _buildUniformLayout(): void;
  17996. /**
  17997. * Sets the passed Effect "effect" with the Light information.
  17998. * @param effect The effect to update
  17999. * @param lightIndex The index of the light in the effect to update
  18000. * @returns The light
  18001. */
  18002. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18003. /**
  18004. * Sets the passed Effect "effect" with the Light textures.
  18005. * @param effect The effect to update
  18006. * @param lightIndex The index of the light in the effect to update
  18007. * @returns The light
  18008. */
  18009. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18010. /**
  18011. * Binds the lights information from the scene to the effect for the given mesh.
  18012. * @param lightIndex Light index
  18013. * @param scene The scene where the light belongs to
  18014. * @param effect The effect we are binding the data to
  18015. * @param useSpecular Defines if specular is supported
  18016. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18017. */
  18018. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18019. /**
  18020. * Sets the passed Effect "effect" with the Light information.
  18021. * @param effect The effect to update
  18022. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18023. * @returns The light
  18024. */
  18025. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18026. /**
  18027. * Returns the string "Light".
  18028. * @returns the class name
  18029. */
  18030. getClassName(): string;
  18031. /** @hidden */
  18032. readonly _isLight: boolean;
  18033. /**
  18034. * Converts the light information to a readable string for debug purpose.
  18035. * @param fullDetails Supports for multiple levels of logging within scene loading
  18036. * @returns the human readable light info
  18037. */
  18038. toString(fullDetails?: boolean): string;
  18039. /** @hidden */
  18040. protected _syncParentEnabledState(): void;
  18041. /**
  18042. * Set the enabled state of this node.
  18043. * @param value - the new enabled state
  18044. */
  18045. setEnabled(value: boolean): void;
  18046. /**
  18047. * Returns the Light associated shadow generator if any.
  18048. * @return the associated shadow generator.
  18049. */
  18050. getShadowGenerator(): Nullable<IShadowGenerator>;
  18051. /**
  18052. * Returns a Vector3, the absolute light position in the World.
  18053. * @returns the world space position of the light
  18054. */
  18055. getAbsolutePosition(): Vector3;
  18056. /**
  18057. * Specifies if the light will affect the passed mesh.
  18058. * @param mesh The mesh to test against the light
  18059. * @return true the mesh is affected otherwise, false.
  18060. */
  18061. canAffectMesh(mesh: AbstractMesh): boolean;
  18062. /**
  18063. * Sort function to order lights for rendering.
  18064. * @param a First Light object to compare to second.
  18065. * @param b Second Light object to compare first.
  18066. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18067. */
  18068. static CompareLightsPriority(a: Light, b: Light): number;
  18069. /**
  18070. * Releases resources associated with this node.
  18071. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18072. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18073. */
  18074. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18075. /**
  18076. * Returns the light type ID (integer).
  18077. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18078. */
  18079. getTypeID(): number;
  18080. /**
  18081. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18082. * @returns the scaled intensity in intensity mode unit
  18083. */
  18084. getScaledIntensity(): number;
  18085. /**
  18086. * Returns a new Light object, named "name", from the current one.
  18087. * @param name The name of the cloned light
  18088. * @param newParent The parent of this light, if it has one
  18089. * @returns the new created light
  18090. */
  18091. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18092. /**
  18093. * Serializes the current light into a Serialization object.
  18094. * @returns the serialized object.
  18095. */
  18096. serialize(): any;
  18097. /**
  18098. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18099. * This new light is named "name" and added to the passed scene.
  18100. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18101. * @param name The friendly name of the light
  18102. * @param scene The scene the new light will belong to
  18103. * @returns the constructor function
  18104. */
  18105. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18106. /**
  18107. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18108. * @param parsedLight The JSON representation of the light
  18109. * @param scene The scene to create the parsed light in
  18110. * @returns the created light after parsing
  18111. */
  18112. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18113. private _hookArrayForExcluded;
  18114. private _hookArrayForIncludedOnly;
  18115. private _resyncMeshes;
  18116. /**
  18117. * Forces the meshes to update their light related information in their rendering used effects
  18118. * @hidden Internal Use Only
  18119. */
  18120. _markMeshesAsLightDirty(): void;
  18121. /**
  18122. * Recomputes the cached photometric scale if needed.
  18123. */
  18124. private _computePhotometricScale;
  18125. /**
  18126. * Returns the Photometric Scale according to the light type and intensity mode.
  18127. */
  18128. private _getPhotometricScale;
  18129. /**
  18130. * Reorder the light in the scene according to their defined priority.
  18131. * @hidden Internal Use Only
  18132. */
  18133. _reorderLightsInScene(): void;
  18134. /**
  18135. * Prepares the list of defines specific to the light type.
  18136. * @param defines the list of defines
  18137. * @param lightIndex defines the index of the light for the effect
  18138. */
  18139. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18140. }
  18141. }
  18142. declare module BABYLON {
  18143. /**
  18144. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18145. * This is the base of the follow, arc rotate cameras and Free camera
  18146. * @see http://doc.babylonjs.com/features/cameras
  18147. */
  18148. export class TargetCamera extends Camera {
  18149. private static _RigCamTransformMatrix;
  18150. private static _TargetTransformMatrix;
  18151. private static _TargetFocalPoint;
  18152. /**
  18153. * Define the current direction the camera is moving to
  18154. */
  18155. cameraDirection: Vector3;
  18156. /**
  18157. * Define the current rotation the camera is rotating to
  18158. */
  18159. cameraRotation: Vector2;
  18160. /**
  18161. * When set, the up vector of the camera will be updated by the rotation of the camera
  18162. */
  18163. updateUpVectorFromRotation: boolean;
  18164. private _tmpQuaternion;
  18165. /**
  18166. * Define the current rotation of the camera
  18167. */
  18168. rotation: Vector3;
  18169. /**
  18170. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18171. */
  18172. rotationQuaternion: Quaternion;
  18173. /**
  18174. * Define the current speed of the camera
  18175. */
  18176. speed: number;
  18177. /**
  18178. * Add constraint to the camera to prevent it to move freely in all directions and
  18179. * around all axis.
  18180. */
  18181. noRotationConstraint: boolean;
  18182. /**
  18183. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18184. * panning
  18185. */
  18186. invertRotation: boolean;
  18187. /**
  18188. * Speed multiplier for inverse camera panning
  18189. */
  18190. inverseRotationSpeed: number;
  18191. /**
  18192. * Define the current target of the camera as an object or a position.
  18193. */
  18194. lockedTarget: any;
  18195. /** @hidden */
  18196. _currentTarget: Vector3;
  18197. /** @hidden */
  18198. _initialFocalDistance: number;
  18199. /** @hidden */
  18200. _viewMatrix: Matrix;
  18201. /** @hidden */
  18202. _camMatrix: Matrix;
  18203. /** @hidden */
  18204. _cameraTransformMatrix: Matrix;
  18205. /** @hidden */
  18206. _cameraRotationMatrix: Matrix;
  18207. /** @hidden */
  18208. _referencePoint: Vector3;
  18209. /** @hidden */
  18210. _transformedReferencePoint: Vector3;
  18211. protected _globalCurrentTarget: Vector3;
  18212. protected _globalCurrentUpVector: Vector3;
  18213. /** @hidden */
  18214. _reset: () => void;
  18215. private _defaultUp;
  18216. /**
  18217. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18218. * This is the base of the follow, arc rotate cameras and Free camera
  18219. * @see http://doc.babylonjs.com/features/cameras
  18220. * @param name Defines the name of the camera in the scene
  18221. * @param position Defines the start position of the camera in the scene
  18222. * @param scene Defines the scene the camera belongs to
  18223. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18224. */
  18225. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18226. /**
  18227. * Gets the position in front of the camera at a given distance.
  18228. * @param distance The distance from the camera we want the position to be
  18229. * @returns the position
  18230. */
  18231. getFrontPosition(distance: number): Vector3;
  18232. /** @hidden */
  18233. _getLockedTargetPosition(): Nullable<Vector3>;
  18234. private _storedPosition;
  18235. private _storedRotation;
  18236. private _storedRotationQuaternion;
  18237. /**
  18238. * Store current camera state of the camera (fov, position, rotation, etc..)
  18239. * @returns the camera
  18240. */
  18241. storeState(): Camera;
  18242. /**
  18243. * Restored camera state. You must call storeState() first
  18244. * @returns whether it was successful or not
  18245. * @hidden
  18246. */
  18247. _restoreStateValues(): boolean;
  18248. /** @hidden */
  18249. _initCache(): void;
  18250. /** @hidden */
  18251. _updateCache(ignoreParentClass?: boolean): void;
  18252. /** @hidden */
  18253. _isSynchronizedViewMatrix(): boolean;
  18254. /** @hidden */
  18255. _computeLocalCameraSpeed(): number;
  18256. /**
  18257. * Defines the target the camera should look at.
  18258. * @param target Defines the new target as a Vector or a mesh
  18259. */
  18260. setTarget(target: Vector3): void;
  18261. /**
  18262. * Return the current target position of the camera. This value is expressed in local space.
  18263. * @returns the target position
  18264. */
  18265. getTarget(): Vector3;
  18266. /** @hidden */
  18267. _decideIfNeedsToMove(): boolean;
  18268. /** @hidden */
  18269. _updatePosition(): void;
  18270. /** @hidden */
  18271. _checkInputs(): void;
  18272. protected _updateCameraRotationMatrix(): void;
  18273. /**
  18274. * 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)
  18275. * @returns the current camera
  18276. */
  18277. private _rotateUpVectorWithCameraRotationMatrix;
  18278. private _cachedRotationZ;
  18279. private _cachedQuaternionRotationZ;
  18280. /** @hidden */
  18281. _getViewMatrix(): Matrix;
  18282. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18283. /**
  18284. * @hidden
  18285. */
  18286. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18287. /**
  18288. * @hidden
  18289. */
  18290. _updateRigCameras(): void;
  18291. private _getRigCamPositionAndTarget;
  18292. /**
  18293. * Gets the current object class name.
  18294. * @return the class name
  18295. */
  18296. getClassName(): string;
  18297. }
  18298. }
  18299. declare module BABYLON {
  18300. /**
  18301. * Gather the list of keyboard event types as constants.
  18302. */
  18303. export class KeyboardEventTypes {
  18304. /**
  18305. * The keydown event is fired when a key becomes active (pressed).
  18306. */
  18307. static readonly KEYDOWN: number;
  18308. /**
  18309. * The keyup event is fired when a key has been released.
  18310. */
  18311. static readonly KEYUP: number;
  18312. }
  18313. /**
  18314. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18315. */
  18316. export class KeyboardInfo {
  18317. /**
  18318. * Defines the type of event (KeyboardEventTypes)
  18319. */
  18320. type: number;
  18321. /**
  18322. * Defines the related dom event
  18323. */
  18324. event: KeyboardEvent;
  18325. /**
  18326. * Instantiates a new keyboard info.
  18327. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18328. * @param type Defines the type of event (KeyboardEventTypes)
  18329. * @param event Defines the related dom event
  18330. */
  18331. constructor(
  18332. /**
  18333. * Defines the type of event (KeyboardEventTypes)
  18334. */
  18335. type: number,
  18336. /**
  18337. * Defines the related dom event
  18338. */
  18339. event: KeyboardEvent);
  18340. }
  18341. /**
  18342. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18343. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18344. */
  18345. export class KeyboardInfoPre extends KeyboardInfo {
  18346. /**
  18347. * Defines the type of event (KeyboardEventTypes)
  18348. */
  18349. type: number;
  18350. /**
  18351. * Defines the related dom event
  18352. */
  18353. event: KeyboardEvent;
  18354. /**
  18355. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18356. */
  18357. skipOnPointerObservable: boolean;
  18358. /**
  18359. * Instantiates a new keyboard pre info.
  18360. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18361. * @param type Defines the type of event (KeyboardEventTypes)
  18362. * @param event Defines the related dom event
  18363. */
  18364. constructor(
  18365. /**
  18366. * Defines the type of event (KeyboardEventTypes)
  18367. */
  18368. type: number,
  18369. /**
  18370. * Defines the related dom event
  18371. */
  18372. event: KeyboardEvent);
  18373. }
  18374. }
  18375. declare module BABYLON {
  18376. /**
  18377. * Manage the keyboard inputs to control the movement of a free camera.
  18378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18379. */
  18380. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18381. /**
  18382. * Defines the camera the input is attached to.
  18383. */
  18384. camera: FreeCamera;
  18385. /**
  18386. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18387. */
  18388. keysUp: number[];
  18389. /**
  18390. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18391. */
  18392. keysUpward: number[];
  18393. /**
  18394. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18395. */
  18396. keysDown: number[];
  18397. /**
  18398. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18399. */
  18400. keysDownward: number[];
  18401. /**
  18402. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18403. */
  18404. keysLeft: number[];
  18405. /**
  18406. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18407. */
  18408. keysRight: number[];
  18409. private _keys;
  18410. private _onCanvasBlurObserver;
  18411. private _onKeyboardObserver;
  18412. private _engine;
  18413. private _scene;
  18414. /**
  18415. * Attach the input controls to a specific dom element to get the input from.
  18416. * @param element Defines the element the controls should be listened from
  18417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18418. */
  18419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18420. /**
  18421. * Detach the current controls from the specified dom element.
  18422. * @param element Defines the element to stop listening the inputs from
  18423. */
  18424. detachControl(element: Nullable<HTMLElement>): void;
  18425. /**
  18426. * Update the current camera state depending on the inputs that have been used this frame.
  18427. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18428. */
  18429. checkInputs(): void;
  18430. /**
  18431. * Gets the class name of the current intput.
  18432. * @returns the class name
  18433. */
  18434. getClassName(): string;
  18435. /** @hidden */
  18436. _onLostFocus(): void;
  18437. /**
  18438. * Get the friendly name associated with the input class.
  18439. * @returns the input friendly name
  18440. */
  18441. getSimpleName(): string;
  18442. }
  18443. }
  18444. declare module BABYLON {
  18445. /**
  18446. * Gather the list of pointer event types as constants.
  18447. */
  18448. export class PointerEventTypes {
  18449. /**
  18450. * 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.
  18451. */
  18452. static readonly POINTERDOWN: number;
  18453. /**
  18454. * The pointerup event is fired when a pointer is no longer active.
  18455. */
  18456. static readonly POINTERUP: number;
  18457. /**
  18458. * The pointermove event is fired when a pointer changes coordinates.
  18459. */
  18460. static readonly POINTERMOVE: number;
  18461. /**
  18462. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18463. */
  18464. static readonly POINTERWHEEL: number;
  18465. /**
  18466. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18467. */
  18468. static readonly POINTERPICK: number;
  18469. /**
  18470. * The pointertap event is fired when a the object has been touched and released without drag.
  18471. */
  18472. static readonly POINTERTAP: number;
  18473. /**
  18474. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18475. */
  18476. static readonly POINTERDOUBLETAP: number;
  18477. }
  18478. /**
  18479. * Base class of pointer info types.
  18480. */
  18481. export class PointerInfoBase {
  18482. /**
  18483. * Defines the type of event (PointerEventTypes)
  18484. */
  18485. type: number;
  18486. /**
  18487. * Defines the related dom event
  18488. */
  18489. event: PointerEvent | MouseWheelEvent;
  18490. /**
  18491. * Instantiates the base class of pointers info.
  18492. * @param type Defines the type of event (PointerEventTypes)
  18493. * @param event Defines the related dom event
  18494. */
  18495. constructor(
  18496. /**
  18497. * Defines the type of event (PointerEventTypes)
  18498. */
  18499. type: number,
  18500. /**
  18501. * Defines the related dom event
  18502. */
  18503. event: PointerEvent | MouseWheelEvent);
  18504. }
  18505. /**
  18506. * This class is used to store pointer related info for the onPrePointerObservable event.
  18507. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18508. */
  18509. export class PointerInfoPre extends PointerInfoBase {
  18510. /**
  18511. * Ray from a pointer if availible (eg. 6dof controller)
  18512. */
  18513. ray: Nullable<Ray>;
  18514. /**
  18515. * Defines the local position of the pointer on the canvas.
  18516. */
  18517. localPosition: Vector2;
  18518. /**
  18519. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18520. */
  18521. skipOnPointerObservable: boolean;
  18522. /**
  18523. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18524. * @param type Defines the type of event (PointerEventTypes)
  18525. * @param event Defines the related dom event
  18526. * @param localX Defines the local x coordinates of the pointer when the event occured
  18527. * @param localY Defines the local y coordinates of the pointer when the event occured
  18528. */
  18529. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18530. }
  18531. /**
  18532. * This type contains all the data related to a pointer event in Babylon.js.
  18533. * 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.
  18534. */
  18535. export class PointerInfo extends PointerInfoBase {
  18536. /**
  18537. * Defines the picking info associated to the info (if any)\
  18538. */
  18539. pickInfo: Nullable<PickingInfo>;
  18540. /**
  18541. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18542. * @param type Defines the type of event (PointerEventTypes)
  18543. * @param event Defines the related dom event
  18544. * @param pickInfo Defines the picking info associated to the info (if any)\
  18545. */
  18546. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18547. /**
  18548. * Defines the picking info associated to the info (if any)\
  18549. */
  18550. pickInfo: Nullable<PickingInfo>);
  18551. }
  18552. /**
  18553. * Data relating to a touch event on the screen.
  18554. */
  18555. export interface PointerTouch {
  18556. /**
  18557. * X coordinate of touch.
  18558. */
  18559. x: number;
  18560. /**
  18561. * Y coordinate of touch.
  18562. */
  18563. y: number;
  18564. /**
  18565. * Id of touch. Unique for each finger.
  18566. */
  18567. pointerId: number;
  18568. /**
  18569. * Event type passed from DOM.
  18570. */
  18571. type: any;
  18572. }
  18573. }
  18574. declare module BABYLON {
  18575. /**
  18576. * Manage the mouse inputs to control the movement of a free camera.
  18577. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18578. */
  18579. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18580. /**
  18581. * Define if touch is enabled in the mouse input
  18582. */
  18583. touchEnabled: boolean;
  18584. /**
  18585. * Defines the camera the input is attached to.
  18586. */
  18587. camera: FreeCamera;
  18588. /**
  18589. * Defines the buttons associated with the input to handle camera move.
  18590. */
  18591. buttons: number[];
  18592. /**
  18593. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18594. */
  18595. angularSensibility: number;
  18596. private _pointerInput;
  18597. private _onMouseMove;
  18598. private _observer;
  18599. private previousPosition;
  18600. /**
  18601. * Observable for when a pointer move event occurs containing the move offset
  18602. */
  18603. onPointerMovedObservable: Observable<{
  18604. offsetX: number;
  18605. offsetY: number;
  18606. }>;
  18607. /**
  18608. * @hidden
  18609. * If the camera should be rotated automatically based on pointer movement
  18610. */
  18611. _allowCameraRotation: boolean;
  18612. /**
  18613. * Manage the mouse inputs to control the movement of a free camera.
  18614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18615. * @param touchEnabled Defines if touch is enabled or not
  18616. */
  18617. constructor(
  18618. /**
  18619. * Define if touch is enabled in the mouse input
  18620. */
  18621. touchEnabled?: boolean);
  18622. /**
  18623. * Attach the input controls to a specific dom element to get the input from.
  18624. * @param element Defines the element the controls should be listened from
  18625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18626. */
  18627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18628. /**
  18629. * Called on JS contextmenu event.
  18630. * Override this method to provide functionality.
  18631. */
  18632. protected onContextMenu(evt: PointerEvent): void;
  18633. /**
  18634. * Detach the current controls from the specified dom element.
  18635. * @param element Defines the element to stop listening the inputs from
  18636. */
  18637. detachControl(element: Nullable<HTMLElement>): void;
  18638. /**
  18639. * Gets the class name of the current intput.
  18640. * @returns the class name
  18641. */
  18642. getClassName(): string;
  18643. /**
  18644. * Get the friendly name associated with the input class.
  18645. * @returns the input friendly name
  18646. */
  18647. getSimpleName(): string;
  18648. }
  18649. }
  18650. declare module BABYLON {
  18651. /**
  18652. * Manage the touch inputs to control the movement of a free camera.
  18653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18654. */
  18655. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18656. /**
  18657. * Defines the camera the input is attached to.
  18658. */
  18659. camera: FreeCamera;
  18660. /**
  18661. * Defines the touch sensibility for rotation.
  18662. * The higher the faster.
  18663. */
  18664. touchAngularSensibility: number;
  18665. /**
  18666. * Defines the touch sensibility for move.
  18667. * The higher the faster.
  18668. */
  18669. touchMoveSensibility: number;
  18670. private _offsetX;
  18671. private _offsetY;
  18672. private _pointerPressed;
  18673. private _pointerInput;
  18674. private _observer;
  18675. private _onLostFocus;
  18676. /**
  18677. * Attach the input controls to a specific dom element to get the input from.
  18678. * @param element Defines the element the controls should be listened from
  18679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18680. */
  18681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18682. /**
  18683. * Detach the current controls from the specified dom element.
  18684. * @param element Defines the element to stop listening the inputs from
  18685. */
  18686. detachControl(element: Nullable<HTMLElement>): void;
  18687. /**
  18688. * Update the current camera state depending on the inputs that have been used this frame.
  18689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18690. */
  18691. checkInputs(): void;
  18692. /**
  18693. * Gets the class name of the current intput.
  18694. * @returns the class name
  18695. */
  18696. getClassName(): string;
  18697. /**
  18698. * Get the friendly name associated with the input class.
  18699. * @returns the input friendly name
  18700. */
  18701. getSimpleName(): string;
  18702. }
  18703. }
  18704. declare module BABYLON {
  18705. /**
  18706. * Default Inputs manager for the FreeCamera.
  18707. * It groups all the default supported inputs for ease of use.
  18708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18709. */
  18710. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18711. /**
  18712. * @hidden
  18713. */
  18714. _mouseInput: Nullable<FreeCameraMouseInput>;
  18715. /**
  18716. * Instantiates a new FreeCameraInputsManager.
  18717. * @param camera Defines the camera the inputs belong to
  18718. */
  18719. constructor(camera: FreeCamera);
  18720. /**
  18721. * Add keyboard input support to the input manager.
  18722. * @returns the current input manager
  18723. */
  18724. addKeyboard(): FreeCameraInputsManager;
  18725. /**
  18726. * Add mouse input support to the input manager.
  18727. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18728. * @returns the current input manager
  18729. */
  18730. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18731. /**
  18732. * Removes the mouse input support from the manager
  18733. * @returns the current input manager
  18734. */
  18735. removeMouse(): FreeCameraInputsManager;
  18736. /**
  18737. * Add touch input support to the input manager.
  18738. * @returns the current input manager
  18739. */
  18740. addTouch(): FreeCameraInputsManager;
  18741. /**
  18742. * Remove all attached input methods from a camera
  18743. */
  18744. clear(): void;
  18745. }
  18746. }
  18747. declare module BABYLON {
  18748. /**
  18749. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18750. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18751. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18752. */
  18753. export class FreeCamera extends TargetCamera {
  18754. /**
  18755. * Define the collision ellipsoid of the camera.
  18756. * This is helpful to simulate a camera body like the player body around the camera
  18757. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18758. */
  18759. ellipsoid: Vector3;
  18760. /**
  18761. * Define an offset for the position of the ellipsoid around the camera.
  18762. * This can be helpful to determine the center of the body near the gravity center of the body
  18763. * instead of its head.
  18764. */
  18765. ellipsoidOffset: Vector3;
  18766. /**
  18767. * Enable or disable collisions of the camera with the rest of the scene objects.
  18768. */
  18769. checkCollisions: boolean;
  18770. /**
  18771. * Enable or disable gravity on the camera.
  18772. */
  18773. applyGravity: boolean;
  18774. /**
  18775. * Define the input manager associated to the camera.
  18776. */
  18777. inputs: FreeCameraInputsManager;
  18778. /**
  18779. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18780. * Higher values reduce sensitivity.
  18781. */
  18782. get angularSensibility(): number;
  18783. /**
  18784. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18785. * Higher values reduce sensitivity.
  18786. */
  18787. set angularSensibility(value: number);
  18788. /**
  18789. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18790. */
  18791. get keysUp(): number[];
  18792. set keysUp(value: number[]);
  18793. /**
  18794. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18795. */
  18796. get keysUpward(): number[];
  18797. set keysUpward(value: number[]);
  18798. /**
  18799. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18800. */
  18801. get keysDown(): number[];
  18802. set keysDown(value: number[]);
  18803. /**
  18804. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18805. */
  18806. get keysDownward(): number[];
  18807. set keysDownward(value: number[]);
  18808. /**
  18809. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18810. */
  18811. get keysLeft(): number[];
  18812. set keysLeft(value: number[]);
  18813. /**
  18814. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18815. */
  18816. get keysRight(): number[];
  18817. set keysRight(value: number[]);
  18818. /**
  18819. * Event raised when the camera collide with a mesh in the scene.
  18820. */
  18821. onCollide: (collidedMesh: AbstractMesh) => void;
  18822. private _collider;
  18823. private _needMoveForGravity;
  18824. private _oldPosition;
  18825. private _diffPosition;
  18826. private _newPosition;
  18827. /** @hidden */
  18828. _localDirection: Vector3;
  18829. /** @hidden */
  18830. _transformedDirection: Vector3;
  18831. /**
  18832. * Instantiates a Free Camera.
  18833. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18834. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18835. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18836. * @param name Define the name of the camera in the scene
  18837. * @param position Define the start position of the camera in the scene
  18838. * @param scene Define the scene the camera belongs to
  18839. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18840. */
  18841. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18842. /**
  18843. * Attached controls to the current camera.
  18844. * @param element Defines the element the controls should be listened from
  18845. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18846. */
  18847. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18848. /**
  18849. * Detach the current controls from the camera.
  18850. * The camera will stop reacting to inputs.
  18851. * @param element Defines the element to stop listening the inputs from
  18852. */
  18853. detachControl(element: HTMLElement): void;
  18854. private _collisionMask;
  18855. /**
  18856. * Define a collision mask to limit the list of object the camera can collide with
  18857. */
  18858. get collisionMask(): number;
  18859. set collisionMask(mask: number);
  18860. /** @hidden */
  18861. _collideWithWorld(displacement: Vector3): void;
  18862. private _onCollisionPositionChange;
  18863. /** @hidden */
  18864. _checkInputs(): void;
  18865. /** @hidden */
  18866. _decideIfNeedsToMove(): boolean;
  18867. /** @hidden */
  18868. _updatePosition(): void;
  18869. /**
  18870. * Destroy the camera and release the current resources hold by it.
  18871. */
  18872. dispose(): void;
  18873. /**
  18874. * Gets the current object class name.
  18875. * @return the class name
  18876. */
  18877. getClassName(): string;
  18878. }
  18879. }
  18880. declare module BABYLON {
  18881. /**
  18882. * Represents a gamepad control stick position
  18883. */
  18884. export class StickValues {
  18885. /**
  18886. * The x component of the control stick
  18887. */
  18888. x: number;
  18889. /**
  18890. * The y component of the control stick
  18891. */
  18892. y: number;
  18893. /**
  18894. * Initializes the gamepad x and y control stick values
  18895. * @param x The x component of the gamepad control stick value
  18896. * @param y The y component of the gamepad control stick value
  18897. */
  18898. constructor(
  18899. /**
  18900. * The x component of the control stick
  18901. */
  18902. x: number,
  18903. /**
  18904. * The y component of the control stick
  18905. */
  18906. y: number);
  18907. }
  18908. /**
  18909. * An interface which manages callbacks for gamepad button changes
  18910. */
  18911. export interface GamepadButtonChanges {
  18912. /**
  18913. * Called when a gamepad has been changed
  18914. */
  18915. changed: boolean;
  18916. /**
  18917. * Called when a gamepad press event has been triggered
  18918. */
  18919. pressChanged: boolean;
  18920. /**
  18921. * Called when a touch event has been triggered
  18922. */
  18923. touchChanged: boolean;
  18924. /**
  18925. * Called when a value has changed
  18926. */
  18927. valueChanged: boolean;
  18928. }
  18929. /**
  18930. * Represents a gamepad
  18931. */
  18932. export class Gamepad {
  18933. /**
  18934. * The id of the gamepad
  18935. */
  18936. id: string;
  18937. /**
  18938. * The index of the gamepad
  18939. */
  18940. index: number;
  18941. /**
  18942. * The browser gamepad
  18943. */
  18944. browserGamepad: any;
  18945. /**
  18946. * Specifies what type of gamepad this represents
  18947. */
  18948. type: number;
  18949. private _leftStick;
  18950. private _rightStick;
  18951. /** @hidden */
  18952. _isConnected: boolean;
  18953. private _leftStickAxisX;
  18954. private _leftStickAxisY;
  18955. private _rightStickAxisX;
  18956. private _rightStickAxisY;
  18957. /**
  18958. * Triggered when the left control stick has been changed
  18959. */
  18960. private _onleftstickchanged;
  18961. /**
  18962. * Triggered when the right control stick has been changed
  18963. */
  18964. private _onrightstickchanged;
  18965. /**
  18966. * Represents a gamepad controller
  18967. */
  18968. static GAMEPAD: number;
  18969. /**
  18970. * Represents a generic controller
  18971. */
  18972. static GENERIC: number;
  18973. /**
  18974. * Represents an XBox controller
  18975. */
  18976. static XBOX: number;
  18977. /**
  18978. * Represents a pose-enabled controller
  18979. */
  18980. static POSE_ENABLED: number;
  18981. /**
  18982. * Represents an Dual Shock controller
  18983. */
  18984. static DUALSHOCK: number;
  18985. /**
  18986. * Specifies whether the left control stick should be Y-inverted
  18987. */
  18988. protected _invertLeftStickY: boolean;
  18989. /**
  18990. * Specifies if the gamepad has been connected
  18991. */
  18992. get isConnected(): boolean;
  18993. /**
  18994. * Initializes the gamepad
  18995. * @param id The id of the gamepad
  18996. * @param index The index of the gamepad
  18997. * @param browserGamepad The browser gamepad
  18998. * @param leftStickX The x component of the left joystick
  18999. * @param leftStickY The y component of the left joystick
  19000. * @param rightStickX The x component of the right joystick
  19001. * @param rightStickY The y component of the right joystick
  19002. */
  19003. constructor(
  19004. /**
  19005. * The id of the gamepad
  19006. */
  19007. id: string,
  19008. /**
  19009. * The index of the gamepad
  19010. */
  19011. index: number,
  19012. /**
  19013. * The browser gamepad
  19014. */
  19015. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19016. /**
  19017. * Callback triggered when the left joystick has changed
  19018. * @param callback
  19019. */
  19020. onleftstickchanged(callback: (values: StickValues) => void): void;
  19021. /**
  19022. * Callback triggered when the right joystick has changed
  19023. * @param callback
  19024. */
  19025. onrightstickchanged(callback: (values: StickValues) => void): void;
  19026. /**
  19027. * Gets the left joystick
  19028. */
  19029. get leftStick(): StickValues;
  19030. /**
  19031. * Sets the left joystick values
  19032. */
  19033. set leftStick(newValues: StickValues);
  19034. /**
  19035. * Gets the right joystick
  19036. */
  19037. get rightStick(): StickValues;
  19038. /**
  19039. * Sets the right joystick value
  19040. */
  19041. set rightStick(newValues: StickValues);
  19042. /**
  19043. * Updates the gamepad joystick positions
  19044. */
  19045. update(): void;
  19046. /**
  19047. * Disposes the gamepad
  19048. */
  19049. dispose(): void;
  19050. }
  19051. /**
  19052. * Represents a generic gamepad
  19053. */
  19054. export class GenericPad extends Gamepad {
  19055. private _buttons;
  19056. private _onbuttondown;
  19057. private _onbuttonup;
  19058. /**
  19059. * Observable triggered when a button has been pressed
  19060. */
  19061. onButtonDownObservable: Observable<number>;
  19062. /**
  19063. * Observable triggered when a button has been released
  19064. */
  19065. onButtonUpObservable: Observable<number>;
  19066. /**
  19067. * Callback triggered when a button has been pressed
  19068. * @param callback Called when a button has been pressed
  19069. */
  19070. onbuttondown(callback: (buttonPressed: number) => void): void;
  19071. /**
  19072. * Callback triggered when a button has been released
  19073. * @param callback Called when a button has been released
  19074. */
  19075. onbuttonup(callback: (buttonReleased: number) => void): void;
  19076. /**
  19077. * Initializes the generic gamepad
  19078. * @param id The id of the generic gamepad
  19079. * @param index The index of the generic gamepad
  19080. * @param browserGamepad The browser gamepad
  19081. */
  19082. constructor(id: string, index: number, browserGamepad: any);
  19083. private _setButtonValue;
  19084. /**
  19085. * Updates the generic gamepad
  19086. */
  19087. update(): void;
  19088. /**
  19089. * Disposes the generic gamepad
  19090. */
  19091. dispose(): void;
  19092. }
  19093. }
  19094. declare module BABYLON {
  19095. /**
  19096. * Defines the types of pose enabled controllers that are supported
  19097. */
  19098. export enum PoseEnabledControllerType {
  19099. /**
  19100. * HTC Vive
  19101. */
  19102. VIVE = 0,
  19103. /**
  19104. * Oculus Rift
  19105. */
  19106. OCULUS = 1,
  19107. /**
  19108. * Windows mixed reality
  19109. */
  19110. WINDOWS = 2,
  19111. /**
  19112. * Samsung gear VR
  19113. */
  19114. GEAR_VR = 3,
  19115. /**
  19116. * Google Daydream
  19117. */
  19118. DAYDREAM = 4,
  19119. /**
  19120. * Generic
  19121. */
  19122. GENERIC = 5
  19123. }
  19124. /**
  19125. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19126. */
  19127. export interface MutableGamepadButton {
  19128. /**
  19129. * Value of the button/trigger
  19130. */
  19131. value: number;
  19132. /**
  19133. * If the button/trigger is currently touched
  19134. */
  19135. touched: boolean;
  19136. /**
  19137. * If the button/trigger is currently pressed
  19138. */
  19139. pressed: boolean;
  19140. }
  19141. /**
  19142. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19143. * @hidden
  19144. */
  19145. export interface ExtendedGamepadButton extends GamepadButton {
  19146. /**
  19147. * If the button/trigger is currently pressed
  19148. */
  19149. readonly pressed: boolean;
  19150. /**
  19151. * If the button/trigger is currently touched
  19152. */
  19153. readonly touched: boolean;
  19154. /**
  19155. * Value of the button/trigger
  19156. */
  19157. readonly value: number;
  19158. }
  19159. /** @hidden */
  19160. export interface _GamePadFactory {
  19161. /**
  19162. * Returns whether or not the current gamepad can be created for this type of controller.
  19163. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19164. * @returns true if it can be created, otherwise false
  19165. */
  19166. canCreate(gamepadInfo: any): boolean;
  19167. /**
  19168. * Creates a new instance of the Gamepad.
  19169. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19170. * @returns the new gamepad instance
  19171. */
  19172. create(gamepadInfo: any): Gamepad;
  19173. }
  19174. /**
  19175. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19176. */
  19177. export class PoseEnabledControllerHelper {
  19178. /** @hidden */
  19179. static _ControllerFactories: _GamePadFactory[];
  19180. /** @hidden */
  19181. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19182. /**
  19183. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19184. * @param vrGamepad the gamepad to initialized
  19185. * @returns a vr controller of the type the gamepad identified as
  19186. */
  19187. static InitiateController(vrGamepad: any): Gamepad;
  19188. }
  19189. /**
  19190. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19191. */
  19192. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19193. /**
  19194. * If the controller is used in a webXR session
  19195. */
  19196. isXR: boolean;
  19197. private _deviceRoomPosition;
  19198. private _deviceRoomRotationQuaternion;
  19199. /**
  19200. * The device position in babylon space
  19201. */
  19202. devicePosition: Vector3;
  19203. /**
  19204. * The device rotation in babylon space
  19205. */
  19206. deviceRotationQuaternion: Quaternion;
  19207. /**
  19208. * The scale factor of the device in babylon space
  19209. */
  19210. deviceScaleFactor: number;
  19211. /**
  19212. * (Likely devicePosition should be used instead) The device position in its room space
  19213. */
  19214. position: Vector3;
  19215. /**
  19216. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19217. */
  19218. rotationQuaternion: Quaternion;
  19219. /**
  19220. * The type of controller (Eg. Windows mixed reality)
  19221. */
  19222. controllerType: PoseEnabledControllerType;
  19223. protected _calculatedPosition: Vector3;
  19224. private _calculatedRotation;
  19225. /**
  19226. * The raw pose from the device
  19227. */
  19228. rawPose: DevicePose;
  19229. private _trackPosition;
  19230. private _maxRotationDistFromHeadset;
  19231. private _draggedRoomRotation;
  19232. /**
  19233. * @hidden
  19234. */
  19235. _disableTrackPosition(fixedPosition: Vector3): void;
  19236. /**
  19237. * Internal, the mesh attached to the controller
  19238. * @hidden
  19239. */
  19240. _mesh: Nullable<AbstractMesh>;
  19241. private _poseControlledCamera;
  19242. private _leftHandSystemQuaternion;
  19243. /**
  19244. * Internal, matrix used to convert room space to babylon space
  19245. * @hidden
  19246. */
  19247. _deviceToWorld: Matrix;
  19248. /**
  19249. * Node to be used when casting a ray from the controller
  19250. * @hidden
  19251. */
  19252. _pointingPoseNode: Nullable<TransformNode>;
  19253. /**
  19254. * Name of the child mesh that can be used to cast a ray from the controller
  19255. */
  19256. static readonly POINTING_POSE: string;
  19257. /**
  19258. * Creates a new PoseEnabledController from a gamepad
  19259. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19260. */
  19261. constructor(browserGamepad: any);
  19262. private _workingMatrix;
  19263. /**
  19264. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19265. */
  19266. update(): void;
  19267. /**
  19268. * Updates only the pose device and mesh without doing any button event checking
  19269. */
  19270. protected _updatePoseAndMesh(): void;
  19271. /**
  19272. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19273. * @param poseData raw pose fromthe device
  19274. */
  19275. updateFromDevice(poseData: DevicePose): void;
  19276. /**
  19277. * @hidden
  19278. */
  19279. _meshAttachedObservable: Observable<AbstractMesh>;
  19280. /**
  19281. * Attaches a mesh to the controller
  19282. * @param mesh the mesh to be attached
  19283. */
  19284. attachToMesh(mesh: AbstractMesh): void;
  19285. /**
  19286. * Attaches the controllers mesh to a camera
  19287. * @param camera the camera the mesh should be attached to
  19288. */
  19289. attachToPoseControlledCamera(camera: TargetCamera): void;
  19290. /**
  19291. * Disposes of the controller
  19292. */
  19293. dispose(): void;
  19294. /**
  19295. * The mesh that is attached to the controller
  19296. */
  19297. get mesh(): Nullable<AbstractMesh>;
  19298. /**
  19299. * Gets the ray of the controller in the direction the controller is pointing
  19300. * @param length the length the resulting ray should be
  19301. * @returns a ray in the direction the controller is pointing
  19302. */
  19303. getForwardRay(length?: number): Ray;
  19304. }
  19305. }
  19306. declare module BABYLON {
  19307. /**
  19308. * Defines the WebVRController object that represents controllers tracked in 3D space
  19309. */
  19310. export abstract class WebVRController extends PoseEnabledController {
  19311. /**
  19312. * Internal, the default controller model for the controller
  19313. */
  19314. protected _defaultModel: Nullable<AbstractMesh>;
  19315. /**
  19316. * Fired when the trigger state has changed
  19317. */
  19318. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19319. /**
  19320. * Fired when the main button state has changed
  19321. */
  19322. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19323. /**
  19324. * Fired when the secondary button state has changed
  19325. */
  19326. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19327. /**
  19328. * Fired when the pad state has changed
  19329. */
  19330. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19331. /**
  19332. * Fired when controllers stick values have changed
  19333. */
  19334. onPadValuesChangedObservable: Observable<StickValues>;
  19335. /**
  19336. * Array of button availible on the controller
  19337. */
  19338. protected _buttons: Array<MutableGamepadButton>;
  19339. private _onButtonStateChange;
  19340. /**
  19341. * Fired when a controller button's state has changed
  19342. * @param callback the callback containing the button that was modified
  19343. */
  19344. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19345. /**
  19346. * X and Y axis corresponding to the controllers joystick
  19347. */
  19348. pad: StickValues;
  19349. /**
  19350. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19351. */
  19352. hand: string;
  19353. /**
  19354. * The default controller model for the controller
  19355. */
  19356. get defaultModel(): Nullable<AbstractMesh>;
  19357. /**
  19358. * Creates a new WebVRController from a gamepad
  19359. * @param vrGamepad the gamepad that the WebVRController should be created from
  19360. */
  19361. constructor(vrGamepad: any);
  19362. /**
  19363. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19364. */
  19365. update(): void;
  19366. /**
  19367. * Function to be called when a button is modified
  19368. */
  19369. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19370. /**
  19371. * Loads a mesh and attaches it to the controller
  19372. * @param scene the scene the mesh should be added to
  19373. * @param meshLoaded callback for when the mesh has been loaded
  19374. */
  19375. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19376. private _setButtonValue;
  19377. private _changes;
  19378. private _checkChanges;
  19379. /**
  19380. * Disposes of th webVRCOntroller
  19381. */
  19382. dispose(): void;
  19383. }
  19384. }
  19385. declare module BABYLON {
  19386. /**
  19387. * The HemisphericLight simulates the ambient environment light,
  19388. * so the passed direction is the light reflection direction, not the incoming direction.
  19389. */
  19390. export class HemisphericLight extends Light {
  19391. /**
  19392. * The groundColor is the light in the opposite direction to the one specified during creation.
  19393. * 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.
  19394. */
  19395. groundColor: Color3;
  19396. /**
  19397. * The light reflection direction, not the incoming direction.
  19398. */
  19399. direction: Vector3;
  19400. /**
  19401. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19402. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19403. * The HemisphericLight can't cast shadows.
  19404. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19405. * @param name The friendly name of the light
  19406. * @param direction The direction of the light reflection
  19407. * @param scene The scene the light belongs to
  19408. */
  19409. constructor(name: string, direction: Vector3, scene: Scene);
  19410. protected _buildUniformLayout(): void;
  19411. /**
  19412. * Returns the string "HemisphericLight".
  19413. * @return The class name
  19414. */
  19415. getClassName(): string;
  19416. /**
  19417. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19418. * Returns the updated direction.
  19419. * @param target The target the direction should point to
  19420. * @return The computed direction
  19421. */
  19422. setDirectionToTarget(target: Vector3): Vector3;
  19423. /**
  19424. * Returns the shadow generator associated to the light.
  19425. * @returns Always null for hemispheric lights because it does not support shadows.
  19426. */
  19427. getShadowGenerator(): Nullable<IShadowGenerator>;
  19428. /**
  19429. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19430. * @param effect The effect to update
  19431. * @param lightIndex The index of the light in the effect to update
  19432. * @returns The hemispheric light
  19433. */
  19434. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19435. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19436. /**
  19437. * Computes the world matrix of the node
  19438. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19439. * @param useWasUpdatedFlag defines a reserved property
  19440. * @returns the world matrix
  19441. */
  19442. computeWorldMatrix(): Matrix;
  19443. /**
  19444. * Returns the integer 3.
  19445. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19446. */
  19447. getTypeID(): number;
  19448. /**
  19449. * Prepares the list of defines specific to the light type.
  19450. * @param defines the list of defines
  19451. * @param lightIndex defines the index of the light for the effect
  19452. */
  19453. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19454. }
  19455. }
  19456. declare module BABYLON {
  19457. /** @hidden */
  19458. export var vrMultiviewToSingleviewPixelShader: {
  19459. name: string;
  19460. shader: string;
  19461. };
  19462. }
  19463. declare module BABYLON {
  19464. /**
  19465. * Renders to multiple views with a single draw call
  19466. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19467. */
  19468. export class MultiviewRenderTarget extends RenderTargetTexture {
  19469. /**
  19470. * Creates a multiview render target
  19471. * @param scene scene used with the render target
  19472. * @param size the size of the render target (used for each view)
  19473. */
  19474. constructor(scene: Scene, size?: number | {
  19475. width: number;
  19476. height: number;
  19477. } | {
  19478. ratio: number;
  19479. });
  19480. /**
  19481. * @hidden
  19482. * @param faceIndex the face index, if its a cube texture
  19483. */
  19484. _bindFrameBuffer(faceIndex?: number): void;
  19485. /**
  19486. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19487. * @returns the view count
  19488. */
  19489. getViewCount(): number;
  19490. }
  19491. }
  19492. declare module BABYLON {
  19493. interface Engine {
  19494. /**
  19495. * Creates a new multiview render target
  19496. * @param width defines the width of the texture
  19497. * @param height defines the height of the texture
  19498. * @returns the created multiview texture
  19499. */
  19500. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19501. /**
  19502. * Binds a multiview framebuffer to be drawn to
  19503. * @param multiviewTexture texture to bind
  19504. */
  19505. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19506. }
  19507. interface Camera {
  19508. /**
  19509. * @hidden
  19510. * 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)
  19511. */
  19512. _useMultiviewToSingleView: boolean;
  19513. /**
  19514. * @hidden
  19515. * 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)
  19516. */
  19517. _multiviewTexture: Nullable<RenderTargetTexture>;
  19518. /**
  19519. * @hidden
  19520. * ensures the multiview texture of the camera exists and has the specified width/height
  19521. * @param width height to set on the multiview texture
  19522. * @param height width to set on the multiview texture
  19523. */
  19524. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19525. }
  19526. interface Scene {
  19527. /** @hidden */
  19528. _transformMatrixR: Matrix;
  19529. /** @hidden */
  19530. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19531. /** @hidden */
  19532. _createMultiviewUbo(): void;
  19533. /** @hidden */
  19534. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19535. /** @hidden */
  19536. _renderMultiviewToSingleView(camera: Camera): void;
  19537. }
  19538. }
  19539. declare module BABYLON {
  19540. /**
  19541. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19542. * This will not be used for webXR as it supports displaying texture arrays directly
  19543. */
  19544. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19545. /**
  19546. * Initializes a VRMultiviewToSingleview
  19547. * @param name name of the post process
  19548. * @param camera camera to be applied to
  19549. * @param scaleFactor scaling factor to the size of the output texture
  19550. */
  19551. constructor(name: string, camera: Camera, scaleFactor: number);
  19552. }
  19553. }
  19554. declare module BABYLON {
  19555. /**
  19556. * Interface used to define additional presentation attributes
  19557. */
  19558. export interface IVRPresentationAttributes {
  19559. /**
  19560. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19561. */
  19562. highRefreshRate: boolean;
  19563. /**
  19564. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19565. */
  19566. foveationLevel: number;
  19567. }
  19568. interface Engine {
  19569. /** @hidden */
  19570. _vrDisplay: any;
  19571. /** @hidden */
  19572. _vrSupported: boolean;
  19573. /** @hidden */
  19574. _oldSize: Size;
  19575. /** @hidden */
  19576. _oldHardwareScaleFactor: number;
  19577. /** @hidden */
  19578. _vrExclusivePointerMode: boolean;
  19579. /** @hidden */
  19580. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19581. /** @hidden */
  19582. _onVRDisplayPointerRestricted: () => void;
  19583. /** @hidden */
  19584. _onVRDisplayPointerUnrestricted: () => void;
  19585. /** @hidden */
  19586. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19587. /** @hidden */
  19588. _onVrDisplayDisconnect: Nullable<() => void>;
  19589. /** @hidden */
  19590. _onVrDisplayPresentChange: Nullable<() => void>;
  19591. /**
  19592. * Observable signaled when VR display mode changes
  19593. */
  19594. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19595. /**
  19596. * Observable signaled when VR request present is complete
  19597. */
  19598. onVRRequestPresentComplete: Observable<boolean>;
  19599. /**
  19600. * Observable signaled when VR request present starts
  19601. */
  19602. onVRRequestPresentStart: Observable<Engine>;
  19603. /**
  19604. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19605. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19606. */
  19607. isInVRExclusivePointerMode: boolean;
  19608. /**
  19609. * Gets a boolean indicating if a webVR device was detected
  19610. * @returns true if a webVR device was detected
  19611. */
  19612. isVRDevicePresent(): boolean;
  19613. /**
  19614. * Gets the current webVR device
  19615. * @returns the current webVR device (or null)
  19616. */
  19617. getVRDevice(): any;
  19618. /**
  19619. * Initializes a webVR display and starts listening to display change events
  19620. * The onVRDisplayChangedObservable will be notified upon these changes
  19621. * @returns A promise containing a VRDisplay and if vr is supported
  19622. */
  19623. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19624. /** @hidden */
  19625. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19626. /**
  19627. * Gets or sets the presentation attributes used to configure VR rendering
  19628. */
  19629. vrPresentationAttributes?: IVRPresentationAttributes;
  19630. /**
  19631. * Call this function to switch to webVR mode
  19632. * Will do nothing if webVR is not supported or if there is no webVR device
  19633. * @param options the webvr options provided to the camera. mainly used for multiview
  19634. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19635. */
  19636. enableVR(options: WebVROptions): void;
  19637. /** @hidden */
  19638. _onVRFullScreenTriggered(): void;
  19639. }
  19640. }
  19641. declare module BABYLON {
  19642. /**
  19643. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19644. * IMPORTANT!! The data is right-hand data.
  19645. * @export
  19646. * @interface DevicePose
  19647. */
  19648. export interface DevicePose {
  19649. /**
  19650. * The position of the device, values in array are [x,y,z].
  19651. */
  19652. readonly position: Nullable<Float32Array>;
  19653. /**
  19654. * The linearVelocity of the device, values in array are [x,y,z].
  19655. */
  19656. readonly linearVelocity: Nullable<Float32Array>;
  19657. /**
  19658. * The linearAcceleration of the device, values in array are [x,y,z].
  19659. */
  19660. readonly linearAcceleration: Nullable<Float32Array>;
  19661. /**
  19662. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19663. */
  19664. readonly orientation: Nullable<Float32Array>;
  19665. /**
  19666. * The angularVelocity of the device, values in array are [x,y,z].
  19667. */
  19668. readonly angularVelocity: Nullable<Float32Array>;
  19669. /**
  19670. * The angularAcceleration of the device, values in array are [x,y,z].
  19671. */
  19672. readonly angularAcceleration: Nullable<Float32Array>;
  19673. }
  19674. /**
  19675. * Interface representing a pose controlled object in Babylon.
  19676. * A pose controlled object has both regular pose values as well as pose values
  19677. * from an external device such as a VR head mounted display
  19678. */
  19679. export interface PoseControlled {
  19680. /**
  19681. * The position of the object in babylon space.
  19682. */
  19683. position: Vector3;
  19684. /**
  19685. * The rotation quaternion of the object in babylon space.
  19686. */
  19687. rotationQuaternion: Quaternion;
  19688. /**
  19689. * The position of the device in babylon space.
  19690. */
  19691. devicePosition?: Vector3;
  19692. /**
  19693. * The rotation quaternion of the device in babylon space.
  19694. */
  19695. deviceRotationQuaternion: Quaternion;
  19696. /**
  19697. * The raw pose coming from the device.
  19698. */
  19699. rawPose: Nullable<DevicePose>;
  19700. /**
  19701. * The scale of the device to be used when translating from device space to babylon space.
  19702. */
  19703. deviceScaleFactor: number;
  19704. /**
  19705. * Updates the poseControlled values based on the input device pose.
  19706. * @param poseData the pose data to update the object with
  19707. */
  19708. updateFromDevice(poseData: DevicePose): void;
  19709. }
  19710. /**
  19711. * Set of options to customize the webVRCamera
  19712. */
  19713. export interface WebVROptions {
  19714. /**
  19715. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19716. */
  19717. trackPosition?: boolean;
  19718. /**
  19719. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19720. */
  19721. positionScale?: number;
  19722. /**
  19723. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19724. */
  19725. displayName?: string;
  19726. /**
  19727. * Should the native controller meshes be initialized. (default: true)
  19728. */
  19729. controllerMeshes?: boolean;
  19730. /**
  19731. * Creating a default HemiLight only on controllers. (default: true)
  19732. */
  19733. defaultLightingOnControllers?: boolean;
  19734. /**
  19735. * If you don't want to use the default VR button of the helper. (default: false)
  19736. */
  19737. useCustomVRButton?: boolean;
  19738. /**
  19739. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19740. */
  19741. customVRButton?: HTMLButtonElement;
  19742. /**
  19743. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19744. */
  19745. rayLength?: number;
  19746. /**
  19747. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19748. */
  19749. defaultHeight?: number;
  19750. /**
  19751. * If multiview should be used if availible (default: false)
  19752. */
  19753. useMultiview?: boolean;
  19754. }
  19755. /**
  19756. * This represents a WebVR camera.
  19757. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19758. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19759. */
  19760. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19761. private webVROptions;
  19762. /**
  19763. * @hidden
  19764. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19765. */
  19766. _vrDevice: any;
  19767. /**
  19768. * The rawPose of the vrDevice.
  19769. */
  19770. rawPose: Nullable<DevicePose>;
  19771. private _onVREnabled;
  19772. private _specsVersion;
  19773. private _attached;
  19774. private _frameData;
  19775. protected _descendants: Array<Node>;
  19776. private _deviceRoomPosition;
  19777. /** @hidden */
  19778. _deviceRoomRotationQuaternion: Quaternion;
  19779. private _standingMatrix;
  19780. /**
  19781. * Represents device position in babylon space.
  19782. */
  19783. devicePosition: Vector3;
  19784. /**
  19785. * Represents device rotation in babylon space.
  19786. */
  19787. deviceRotationQuaternion: Quaternion;
  19788. /**
  19789. * The scale of the device to be used when translating from device space to babylon space.
  19790. */
  19791. deviceScaleFactor: number;
  19792. private _deviceToWorld;
  19793. private _worldToDevice;
  19794. /**
  19795. * References to the webVR controllers for the vrDevice.
  19796. */
  19797. controllers: Array<WebVRController>;
  19798. /**
  19799. * Emits an event when a controller is attached.
  19800. */
  19801. onControllersAttachedObservable: Observable<WebVRController[]>;
  19802. /**
  19803. * Emits an event when a controller's mesh has been loaded;
  19804. */
  19805. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19806. /**
  19807. * Emits an event when the HMD's pose has been updated.
  19808. */
  19809. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19810. private _poseSet;
  19811. /**
  19812. * If the rig cameras be used as parent instead of this camera.
  19813. */
  19814. rigParenting: boolean;
  19815. private _lightOnControllers;
  19816. private _defaultHeight?;
  19817. /**
  19818. * Instantiates a WebVRFreeCamera.
  19819. * @param name The name of the WebVRFreeCamera
  19820. * @param position The starting anchor position for the camera
  19821. * @param scene The scene the camera belongs to
  19822. * @param webVROptions a set of customizable options for the webVRCamera
  19823. */
  19824. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19825. /**
  19826. * Gets the device distance from the ground in meters.
  19827. * @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.
  19828. */
  19829. deviceDistanceToRoomGround(): number;
  19830. /**
  19831. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19832. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19833. */
  19834. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19835. /**
  19836. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19837. * @returns A promise with a boolean set to if the standing matrix is supported.
  19838. */
  19839. useStandingMatrixAsync(): Promise<boolean>;
  19840. /**
  19841. * Disposes the camera
  19842. */
  19843. dispose(): void;
  19844. /**
  19845. * Gets a vrController by name.
  19846. * @param name The name of the controller to retreive
  19847. * @returns the controller matching the name specified or null if not found
  19848. */
  19849. getControllerByName(name: string): Nullable<WebVRController>;
  19850. private _leftController;
  19851. /**
  19852. * The controller corresponding to the users left hand.
  19853. */
  19854. get leftController(): Nullable<WebVRController>;
  19855. private _rightController;
  19856. /**
  19857. * The controller corresponding to the users right hand.
  19858. */
  19859. get rightController(): Nullable<WebVRController>;
  19860. /**
  19861. * Casts a ray forward from the vrCamera's gaze.
  19862. * @param length Length of the ray (default: 100)
  19863. * @returns the ray corresponding to the gaze
  19864. */
  19865. getForwardRay(length?: number): Ray;
  19866. /**
  19867. * @hidden
  19868. * Updates the camera based on device's frame data
  19869. */
  19870. _checkInputs(): void;
  19871. /**
  19872. * Updates the poseControlled values based on the input device pose.
  19873. * @param poseData Pose coming from the device
  19874. */
  19875. updateFromDevice(poseData: DevicePose): void;
  19876. private _htmlElementAttached;
  19877. private _detachIfAttached;
  19878. /**
  19879. * WebVR's attach control will start broadcasting frames to the device.
  19880. * Note that in certain browsers (chrome for example) this function must be called
  19881. * within a user-interaction callback. Example:
  19882. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19883. *
  19884. * @param element html element to attach the vrDevice to
  19885. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19886. */
  19887. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19888. /**
  19889. * Detaches the camera from the html element and disables VR
  19890. *
  19891. * @param element html element to detach from
  19892. */
  19893. detachControl(element: HTMLElement): void;
  19894. /**
  19895. * @returns the name of this class
  19896. */
  19897. getClassName(): string;
  19898. /**
  19899. * Calls resetPose on the vrDisplay
  19900. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19901. */
  19902. resetToCurrentRotation(): void;
  19903. /**
  19904. * @hidden
  19905. * Updates the rig cameras (left and right eye)
  19906. */
  19907. _updateRigCameras(): void;
  19908. private _workingVector;
  19909. private _oneVector;
  19910. private _workingMatrix;
  19911. private updateCacheCalled;
  19912. private _correctPositionIfNotTrackPosition;
  19913. /**
  19914. * @hidden
  19915. * Updates the cached values of the camera
  19916. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19917. */
  19918. _updateCache(ignoreParentClass?: boolean): void;
  19919. /**
  19920. * @hidden
  19921. * Get current device position in babylon world
  19922. */
  19923. _computeDevicePosition(): void;
  19924. /**
  19925. * Updates the current device position and rotation in the babylon world
  19926. */
  19927. update(): void;
  19928. /**
  19929. * @hidden
  19930. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19931. * @returns an identity matrix
  19932. */
  19933. _getViewMatrix(): Matrix;
  19934. private _tmpMatrix;
  19935. /**
  19936. * This function is called by the two RIG cameras.
  19937. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19938. * @hidden
  19939. */
  19940. _getWebVRViewMatrix(): Matrix;
  19941. /** @hidden */
  19942. _getWebVRProjectionMatrix(): Matrix;
  19943. private _onGamepadConnectedObserver;
  19944. private _onGamepadDisconnectedObserver;
  19945. private _updateCacheWhenTrackingDisabledObserver;
  19946. /**
  19947. * Initializes the controllers and their meshes
  19948. */
  19949. initControllers(): void;
  19950. }
  19951. }
  19952. declare module BABYLON {
  19953. /**
  19954. * "Static Class" containing the most commonly used helper while dealing with material for
  19955. * rendering purpose.
  19956. *
  19957. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19958. *
  19959. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19960. */
  19961. export class MaterialHelper {
  19962. /**
  19963. * Bind the current view position to an effect.
  19964. * @param effect The effect to be bound
  19965. * @param scene The scene the eyes position is used from
  19966. * @param variableName name of the shader variable that will hold the eye position
  19967. */
  19968. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19969. /**
  19970. * Helps preparing the defines values about the UVs in used in the effect.
  19971. * UVs are shared as much as we can accross channels in the shaders.
  19972. * @param texture The texture we are preparing the UVs for
  19973. * @param defines The defines to update
  19974. * @param key The channel key "diffuse", "specular"... used in the shader
  19975. */
  19976. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19977. /**
  19978. * Binds a texture matrix value to its corrsponding uniform
  19979. * @param texture The texture to bind the matrix for
  19980. * @param uniformBuffer The uniform buffer receivin the data
  19981. * @param key The channel key "diffuse", "specular"... used in the shader
  19982. */
  19983. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19984. /**
  19985. * Gets the current status of the fog (should it be enabled?)
  19986. * @param mesh defines the mesh to evaluate for fog support
  19987. * @param scene defines the hosting scene
  19988. * @returns true if fog must be enabled
  19989. */
  19990. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  19991. /**
  19992. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  19993. * @param mesh defines the current mesh
  19994. * @param scene defines the current scene
  19995. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  19996. * @param pointsCloud defines if point cloud rendering has to be turned on
  19997. * @param fogEnabled defines if fog has to be turned on
  19998. * @param alphaTest defines if alpha testing has to be turned on
  19999. * @param defines defines the current list of defines
  20000. */
  20001. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20002. /**
  20003. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20004. * @param scene defines the current scene
  20005. * @param engine defines the current engine
  20006. * @param defines specifies the list of active defines
  20007. * @param useInstances defines if instances have to be turned on
  20008. * @param useClipPlane defines if clip plane have to be turned on
  20009. */
  20010. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  20011. /**
  20012. * Prepares the defines for bones
  20013. * @param mesh The mesh containing the geometry data we will draw
  20014. * @param defines The defines to update
  20015. */
  20016. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20017. /**
  20018. * Prepares the defines for morph targets
  20019. * @param mesh The mesh containing the geometry data we will draw
  20020. * @param defines The defines to update
  20021. */
  20022. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20023. /**
  20024. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20025. * @param mesh The mesh containing the geometry data we will draw
  20026. * @param defines The defines to update
  20027. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20028. * @param useBones Precise whether bones should be used or not (override mesh info)
  20029. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20030. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20031. * @returns false if defines are considered not dirty and have not been checked
  20032. */
  20033. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20034. /**
  20035. * Prepares the defines related to multiview
  20036. * @param scene The scene we are intending to draw
  20037. * @param defines The defines to update
  20038. */
  20039. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20040. /**
  20041. * Prepares the defines related to the light information passed in parameter
  20042. * @param scene The scene we are intending to draw
  20043. * @param mesh The mesh the effect is compiling for
  20044. * @param light The light the effect is compiling for
  20045. * @param lightIndex The index of the light
  20046. * @param defines The defines to update
  20047. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20048. * @param state Defines the current state regarding what is needed (normals, etc...)
  20049. */
  20050. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20051. needNormals: boolean;
  20052. needRebuild: boolean;
  20053. shadowEnabled: boolean;
  20054. specularEnabled: boolean;
  20055. lightmapMode: boolean;
  20056. }): void;
  20057. /**
  20058. * Prepares the defines related to the light information passed in parameter
  20059. * @param scene The scene we are intending to draw
  20060. * @param mesh The mesh the effect is compiling for
  20061. * @param defines The defines to update
  20062. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20063. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20064. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20065. * @returns true if normals will be required for the rest of the effect
  20066. */
  20067. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20068. /**
  20069. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20070. * @param lightIndex defines the light index
  20071. * @param uniformsList The uniform list
  20072. * @param samplersList The sampler list
  20073. * @param projectedLightTexture defines if projected texture must be used
  20074. * @param uniformBuffersList defines an optional list of uniform buffers
  20075. */
  20076. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20077. /**
  20078. * Prepares the uniforms and samplers list to be used in the effect
  20079. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20080. * @param samplersList The sampler list
  20081. * @param defines The defines helping in the list generation
  20082. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20083. */
  20084. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20085. /**
  20086. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20087. * @param defines The defines to update while falling back
  20088. * @param fallbacks The authorized effect fallbacks
  20089. * @param maxSimultaneousLights The maximum number of lights allowed
  20090. * @param rank the current rank of the Effect
  20091. * @returns The newly affected rank
  20092. */
  20093. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20094. private static _TmpMorphInfluencers;
  20095. /**
  20096. * Prepares the list of attributes required for morph targets according to the effect defines.
  20097. * @param attribs The current list of supported attribs
  20098. * @param mesh The mesh to prepare the morph targets attributes for
  20099. * @param influencers The number of influencers
  20100. */
  20101. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20102. /**
  20103. * Prepares the list of attributes required for morph targets according to the effect defines.
  20104. * @param attribs The current list of supported attribs
  20105. * @param mesh The mesh to prepare the morph targets attributes for
  20106. * @param defines The current Defines of the effect
  20107. */
  20108. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20109. /**
  20110. * Prepares the list of attributes required for bones according to the effect defines.
  20111. * @param attribs The current list of supported attribs
  20112. * @param mesh The mesh to prepare the bones attributes for
  20113. * @param defines The current Defines of the effect
  20114. * @param fallbacks The current efffect fallback strategy
  20115. */
  20116. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20117. /**
  20118. * Check and prepare the list of attributes required for instances according to the effect defines.
  20119. * @param attribs The current list of supported attribs
  20120. * @param defines The current MaterialDefines of the effect
  20121. */
  20122. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20123. /**
  20124. * Add the list of attributes required for instances to the attribs array.
  20125. * @param attribs The current list of supported attribs
  20126. */
  20127. static PushAttributesForInstances(attribs: string[]): void;
  20128. /**
  20129. * Binds the light information to the effect.
  20130. * @param light The light containing the generator
  20131. * @param effect The effect we are binding the data to
  20132. * @param lightIndex The light index in the effect used to render
  20133. */
  20134. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20135. /**
  20136. * Binds the lights information from the scene to the effect for the given mesh.
  20137. * @param light Light to bind
  20138. * @param lightIndex Light index
  20139. * @param scene The scene where the light belongs to
  20140. * @param effect The effect we are binding the data to
  20141. * @param useSpecular Defines if specular is supported
  20142. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20143. */
  20144. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20145. /**
  20146. * Binds the lights information from the scene to the effect for the given mesh.
  20147. * @param scene The scene the lights belongs to
  20148. * @param mesh The mesh we are binding the information to render
  20149. * @param effect The effect we are binding the data to
  20150. * @param defines The generated defines for the effect
  20151. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20152. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20153. */
  20154. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20155. private static _tempFogColor;
  20156. /**
  20157. * Binds the fog information from the scene to the effect for the given mesh.
  20158. * @param scene The scene the lights belongs to
  20159. * @param mesh The mesh we are binding the information to render
  20160. * @param effect The effect we are binding the data to
  20161. * @param linearSpace Defines if the fog effect is applied in linear space
  20162. */
  20163. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20164. /**
  20165. * Binds the bones information from the mesh to the effect.
  20166. * @param mesh The mesh we are binding the information to render
  20167. * @param effect The effect we are binding the data to
  20168. */
  20169. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20170. /**
  20171. * Binds the morph targets information from the mesh to the effect.
  20172. * @param abstractMesh The mesh we are binding the information to render
  20173. * @param effect The effect we are binding the data to
  20174. */
  20175. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20176. /**
  20177. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20178. * @param defines The generated defines used in the effect
  20179. * @param effect The effect we are binding the data to
  20180. * @param scene The scene we are willing to render with logarithmic scale for
  20181. */
  20182. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20183. /**
  20184. * Binds the clip plane information from the scene to the effect.
  20185. * @param scene The scene the clip plane information are extracted from
  20186. * @param effect The effect we are binding the data to
  20187. */
  20188. static BindClipPlane(effect: Effect, scene: Scene): void;
  20189. }
  20190. }
  20191. declare module BABYLON {
  20192. /**
  20193. * Block used to expose an input value
  20194. */
  20195. export class InputBlock extends NodeMaterialBlock {
  20196. private _mode;
  20197. private _associatedVariableName;
  20198. private _storedValue;
  20199. private _valueCallback;
  20200. private _type;
  20201. private _animationType;
  20202. /** Gets or set a value used to limit the range of float values */
  20203. min: number;
  20204. /** Gets or set a value used to limit the range of float values */
  20205. max: number;
  20206. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20207. isBoolean: boolean;
  20208. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20209. matrixMode: number;
  20210. /** @hidden */
  20211. _systemValue: Nullable<NodeMaterialSystemValues>;
  20212. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20213. visibleInInspector: boolean;
  20214. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20215. isConstant: boolean;
  20216. /** Gets or sets the group to use to display this block in the Inspector */
  20217. groupInInspector: string;
  20218. /** Gets an observable raised when the value is changed */
  20219. onValueChangedObservable: Observable<InputBlock>;
  20220. /**
  20221. * Gets or sets the connection point type (default is float)
  20222. */
  20223. get type(): NodeMaterialBlockConnectionPointTypes;
  20224. /**
  20225. * Creates a new InputBlock
  20226. * @param name defines the block name
  20227. * @param target defines the target of that block (Vertex by default)
  20228. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20229. */
  20230. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20231. /**
  20232. * Gets the output component
  20233. */
  20234. get output(): NodeMaterialConnectionPoint;
  20235. /**
  20236. * Set the source of this connection point to a vertex attribute
  20237. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20238. * @returns the current connection point
  20239. */
  20240. setAsAttribute(attributeName?: string): InputBlock;
  20241. /**
  20242. * Set the source of this connection point to a system value
  20243. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20244. * @returns the current connection point
  20245. */
  20246. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20247. /**
  20248. * Gets or sets the value of that point.
  20249. * Please note that this value will be ignored if valueCallback is defined
  20250. */
  20251. get value(): any;
  20252. set value(value: any);
  20253. /**
  20254. * Gets or sets a callback used to get the value of that point.
  20255. * Please note that setting this value will force the connection point to ignore the value property
  20256. */
  20257. get valueCallback(): () => any;
  20258. set valueCallback(value: () => any);
  20259. /**
  20260. * Gets or sets the associated variable name in the shader
  20261. */
  20262. get associatedVariableName(): string;
  20263. set associatedVariableName(value: string);
  20264. /** Gets or sets the type of animation applied to the input */
  20265. get animationType(): AnimatedInputBlockTypes;
  20266. set animationType(value: AnimatedInputBlockTypes);
  20267. /**
  20268. * Gets a boolean indicating that this connection point not defined yet
  20269. */
  20270. get isUndefined(): boolean;
  20271. /**
  20272. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20273. * In this case the connection point name must be the name of the uniform to use.
  20274. * Can only be set on inputs
  20275. */
  20276. get isUniform(): boolean;
  20277. set isUniform(value: boolean);
  20278. /**
  20279. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20280. * In this case the connection point name must be the name of the attribute to use
  20281. * Can only be set on inputs
  20282. */
  20283. get isAttribute(): boolean;
  20284. set isAttribute(value: boolean);
  20285. /**
  20286. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20287. * Can only be set on exit points
  20288. */
  20289. get isVarying(): boolean;
  20290. set isVarying(value: boolean);
  20291. /**
  20292. * Gets a boolean indicating that the current connection point is a system value
  20293. */
  20294. get isSystemValue(): boolean;
  20295. /**
  20296. * Gets or sets the current well known value or null if not defined as a system value
  20297. */
  20298. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20299. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20300. /**
  20301. * Gets the current class name
  20302. * @returns the class name
  20303. */
  20304. getClassName(): string;
  20305. /**
  20306. * Animate the input if animationType !== None
  20307. * @param scene defines the rendering scene
  20308. */
  20309. animate(scene: Scene): void;
  20310. private _emitDefine;
  20311. initialize(state: NodeMaterialBuildState): void;
  20312. /**
  20313. * Set the input block to its default value (based on its type)
  20314. */
  20315. setDefaultValue(): void;
  20316. private _emitConstant;
  20317. /** @hidden */
  20318. get _noContextSwitch(): boolean;
  20319. private _emit;
  20320. /** @hidden */
  20321. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20322. /** @hidden */
  20323. _transmit(effect: Effect, scene: Scene): void;
  20324. protected _buildBlock(state: NodeMaterialBuildState): void;
  20325. protected _dumpPropertiesCode(): string;
  20326. dispose(): void;
  20327. serialize(): any;
  20328. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20329. }
  20330. }
  20331. declare module BABYLON {
  20332. /**
  20333. * Enum used to define the compatibility state between two connection points
  20334. */
  20335. export enum NodeMaterialConnectionPointCompatibilityStates {
  20336. /** Points are compatibles */
  20337. Compatible = 0,
  20338. /** Points are incompatible because of their types */
  20339. TypeIncompatible = 1,
  20340. /** Points are incompatible because of their targets (vertex vs fragment) */
  20341. TargetIncompatible = 2
  20342. }
  20343. /**
  20344. * Defines the direction of a connection point
  20345. */
  20346. export enum NodeMaterialConnectionPointDirection {
  20347. /** Input */
  20348. Input = 0,
  20349. /** Output */
  20350. Output = 1
  20351. }
  20352. /**
  20353. * Defines a connection point for a block
  20354. */
  20355. export class NodeMaterialConnectionPoint {
  20356. /** @hidden */
  20357. _ownerBlock: NodeMaterialBlock;
  20358. /** @hidden */
  20359. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20360. private _endpoints;
  20361. private _associatedVariableName;
  20362. private _direction;
  20363. /** @hidden */
  20364. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20365. /** @hidden */
  20366. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20367. private _type;
  20368. /** @hidden */
  20369. _enforceAssociatedVariableName: boolean;
  20370. /** Gets the direction of the point */
  20371. get direction(): NodeMaterialConnectionPointDirection;
  20372. /** Indicates that this connection point needs dual validation before being connected to another point */
  20373. needDualDirectionValidation: boolean;
  20374. /**
  20375. * Gets or sets the additional types supported by this connection point
  20376. */
  20377. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20378. /**
  20379. * Gets or sets the additional types excluded by this connection point
  20380. */
  20381. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20382. /**
  20383. * Observable triggered when this point is connected
  20384. */
  20385. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20386. /**
  20387. * Gets or sets the associated variable name in the shader
  20388. */
  20389. get associatedVariableName(): string;
  20390. set associatedVariableName(value: string);
  20391. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20392. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20393. /**
  20394. * Gets or sets the connection point type (default is float)
  20395. */
  20396. get type(): NodeMaterialBlockConnectionPointTypes;
  20397. set type(value: NodeMaterialBlockConnectionPointTypes);
  20398. /**
  20399. * Gets or sets the connection point name
  20400. */
  20401. name: string;
  20402. /**
  20403. * Gets or sets the connection point name
  20404. */
  20405. displayName: string;
  20406. /**
  20407. * Gets or sets a boolean indicating that this connection point can be omitted
  20408. */
  20409. isOptional: boolean;
  20410. /**
  20411. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20412. */
  20413. define: string;
  20414. /** @hidden */
  20415. _prioritizeVertex: boolean;
  20416. private _target;
  20417. /** Gets or sets the target of that connection point */
  20418. get target(): NodeMaterialBlockTargets;
  20419. set target(value: NodeMaterialBlockTargets);
  20420. /**
  20421. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20422. */
  20423. get isConnected(): boolean;
  20424. /**
  20425. * Gets a boolean indicating that the current point is connected to an input block
  20426. */
  20427. get isConnectedToInputBlock(): boolean;
  20428. /**
  20429. * Gets a the connected input block (if any)
  20430. */
  20431. get connectInputBlock(): Nullable<InputBlock>;
  20432. /** Get the other side of the connection (if any) */
  20433. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20434. /** Get the block that owns this connection point */
  20435. get ownerBlock(): NodeMaterialBlock;
  20436. /** Get the block connected on the other side of this connection (if any) */
  20437. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20438. /** Get the block connected on the endpoints of this connection (if any) */
  20439. get connectedBlocks(): Array<NodeMaterialBlock>;
  20440. /** Gets the list of connected endpoints */
  20441. get endpoints(): NodeMaterialConnectionPoint[];
  20442. /** Gets a boolean indicating if that output point is connected to at least one input */
  20443. get hasEndpoints(): boolean;
  20444. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20445. get isConnectedInVertexShader(): boolean;
  20446. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20447. get isConnectedInFragmentShader(): boolean;
  20448. /**
  20449. * Creates a block suitable to be used as an input for this input point.
  20450. * If null is returned, a block based on the point type will be created.
  20451. * @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
  20452. */
  20453. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20454. /**
  20455. * Creates a new connection point
  20456. * @param name defines the connection point name
  20457. * @param ownerBlock defines the block hosting this connection point
  20458. * @param direction defines the direction of the connection point
  20459. */
  20460. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20461. /**
  20462. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20463. * @returns the class name
  20464. */
  20465. getClassName(): string;
  20466. /**
  20467. * Gets a boolean indicating if the current point can be connected to another point
  20468. * @param connectionPoint defines the other connection point
  20469. * @returns a boolean
  20470. */
  20471. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20472. /**
  20473. * Gets a number indicating if the current point can be connected to another point
  20474. * @param connectionPoint defines the other connection point
  20475. * @returns a number defining the compatibility state
  20476. */
  20477. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20478. /**
  20479. * Connect this point to another connection point
  20480. * @param connectionPoint defines the other connection point
  20481. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20482. * @returns the current connection point
  20483. */
  20484. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20485. /**
  20486. * Disconnect this point from one of his endpoint
  20487. * @param endpoint defines the other connection point
  20488. * @returns the current connection point
  20489. */
  20490. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20491. /**
  20492. * Serializes this point in a JSON representation
  20493. * @param isInput defines if the connection point is an input (default is true)
  20494. * @returns the serialized point object
  20495. */
  20496. serialize(isInput?: boolean): any;
  20497. /**
  20498. * Release resources
  20499. */
  20500. dispose(): void;
  20501. }
  20502. }
  20503. declare module BABYLON {
  20504. /**
  20505. * Enum used to define the material modes
  20506. */
  20507. export enum NodeMaterialModes {
  20508. /** Regular material */
  20509. Material = 0,
  20510. /** For post process */
  20511. PostProcess = 1,
  20512. /** For particle system */
  20513. Particle = 2
  20514. }
  20515. }
  20516. declare module BABYLON {
  20517. /**
  20518. * Block used to read a texture from a sampler
  20519. */
  20520. export class TextureBlock extends NodeMaterialBlock {
  20521. private _defineName;
  20522. private _linearDefineName;
  20523. private _gammaDefineName;
  20524. private _tempTextureRead;
  20525. private _samplerName;
  20526. private _transformedUVName;
  20527. private _textureTransformName;
  20528. private _textureInfoName;
  20529. private _mainUVName;
  20530. private _mainUVDefineName;
  20531. private _fragmentOnly;
  20532. /**
  20533. * Gets or sets the texture associated with the node
  20534. */
  20535. texture: Nullable<Texture>;
  20536. /**
  20537. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20538. */
  20539. convertToGammaSpace: boolean;
  20540. /**
  20541. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20542. */
  20543. convertToLinearSpace: boolean;
  20544. /**
  20545. * Create a new TextureBlock
  20546. * @param name defines the block name
  20547. */
  20548. constructor(name: string, fragmentOnly?: boolean);
  20549. /**
  20550. * Gets the current class name
  20551. * @returns the class name
  20552. */
  20553. getClassName(): string;
  20554. /**
  20555. * Gets the uv input component
  20556. */
  20557. get uv(): NodeMaterialConnectionPoint;
  20558. /**
  20559. * Gets the rgba output component
  20560. */
  20561. get rgba(): NodeMaterialConnectionPoint;
  20562. /**
  20563. * Gets the rgb output component
  20564. */
  20565. get rgb(): NodeMaterialConnectionPoint;
  20566. /**
  20567. * Gets the r output component
  20568. */
  20569. get r(): NodeMaterialConnectionPoint;
  20570. /**
  20571. * Gets the g output component
  20572. */
  20573. get g(): NodeMaterialConnectionPoint;
  20574. /**
  20575. * Gets the b output component
  20576. */
  20577. get b(): NodeMaterialConnectionPoint;
  20578. /**
  20579. * Gets the a output component
  20580. */
  20581. get a(): NodeMaterialConnectionPoint;
  20582. get target(): NodeMaterialBlockTargets;
  20583. autoConfigure(material: NodeMaterial): void;
  20584. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20585. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20586. isReady(): boolean;
  20587. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20588. private get _isMixed();
  20589. private _injectVertexCode;
  20590. private _writeTextureRead;
  20591. private _writeOutput;
  20592. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20593. protected _dumpPropertiesCode(): string;
  20594. serialize(): any;
  20595. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20596. }
  20597. }
  20598. declare module BABYLON {
  20599. /** @hidden */
  20600. export var reflectionFunction: {
  20601. name: string;
  20602. shader: string;
  20603. };
  20604. }
  20605. declare module BABYLON {
  20606. /**
  20607. * Base block used to read a reflection texture from a sampler
  20608. */
  20609. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20610. /** @hidden */
  20611. _define3DName: string;
  20612. /** @hidden */
  20613. _defineCubicName: string;
  20614. /** @hidden */
  20615. _defineExplicitName: string;
  20616. /** @hidden */
  20617. _defineProjectionName: string;
  20618. /** @hidden */
  20619. _defineLocalCubicName: string;
  20620. /** @hidden */
  20621. _defineSphericalName: string;
  20622. /** @hidden */
  20623. _definePlanarName: string;
  20624. /** @hidden */
  20625. _defineEquirectangularName: string;
  20626. /** @hidden */
  20627. _defineMirroredEquirectangularFixedName: string;
  20628. /** @hidden */
  20629. _defineEquirectangularFixedName: string;
  20630. /** @hidden */
  20631. _defineSkyboxName: string;
  20632. /** @hidden */
  20633. _defineOppositeZ: string;
  20634. /** @hidden */
  20635. _cubeSamplerName: string;
  20636. /** @hidden */
  20637. _2DSamplerName: string;
  20638. protected _positionUVWName: string;
  20639. protected _directionWName: string;
  20640. protected _reflectionVectorName: string;
  20641. /** @hidden */
  20642. _reflectionCoordsName: string;
  20643. /** @hidden */
  20644. _reflectionMatrixName: string;
  20645. protected _reflectionColorName: string;
  20646. /**
  20647. * Gets or sets the texture associated with the node
  20648. */
  20649. texture: Nullable<BaseTexture>;
  20650. /**
  20651. * Create a new ReflectionTextureBaseBlock
  20652. * @param name defines the block name
  20653. */
  20654. constructor(name: string);
  20655. /**
  20656. * Gets the current class name
  20657. * @returns the class name
  20658. */
  20659. getClassName(): string;
  20660. /**
  20661. * Gets the world position input component
  20662. */
  20663. abstract get position(): NodeMaterialConnectionPoint;
  20664. /**
  20665. * Gets the world position input component
  20666. */
  20667. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20668. /**
  20669. * Gets the world normal input component
  20670. */
  20671. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20672. /**
  20673. * Gets the world input component
  20674. */
  20675. abstract get world(): NodeMaterialConnectionPoint;
  20676. /**
  20677. * Gets the camera (or eye) position component
  20678. */
  20679. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20680. /**
  20681. * Gets the view input component
  20682. */
  20683. abstract get view(): NodeMaterialConnectionPoint;
  20684. protected _getTexture(): Nullable<BaseTexture>;
  20685. autoConfigure(material: NodeMaterial): void;
  20686. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20687. isReady(): boolean;
  20688. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20689. /**
  20690. * Gets the code to inject in the vertex shader
  20691. * @param state current state of the node material building
  20692. * @returns the shader code
  20693. */
  20694. handleVertexSide(state: NodeMaterialBuildState): string;
  20695. /**
  20696. * Handles the inits for the fragment code path
  20697. * @param state node material build state
  20698. */
  20699. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20700. /**
  20701. * Generates the reflection coords code for the fragment code path
  20702. * @param worldNormalVarName name of the world normal variable
  20703. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20704. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20705. * @returns the shader code
  20706. */
  20707. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20708. /**
  20709. * Generates the reflection color code for the fragment code path
  20710. * @param lodVarName name of the lod variable
  20711. * @param swizzleLookupTexture swizzle to use for the final color variable
  20712. * @returns the shader code
  20713. */
  20714. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20715. /**
  20716. * Generates the code corresponding to the connected output points
  20717. * @param state node material build state
  20718. * @param varName name of the variable to output
  20719. * @returns the shader code
  20720. */
  20721. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20722. protected _buildBlock(state: NodeMaterialBuildState): this;
  20723. protected _dumpPropertiesCode(): string;
  20724. serialize(): any;
  20725. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20726. }
  20727. }
  20728. declare module BABYLON {
  20729. /**
  20730. * Defines a connection point to be used for points with a custom object type
  20731. */
  20732. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20733. private _blockType;
  20734. private _blockName;
  20735. private _nameForCheking?;
  20736. /**
  20737. * Creates a new connection point
  20738. * @param name defines the connection point name
  20739. * @param ownerBlock defines the block hosting this connection point
  20740. * @param direction defines the direction of the connection point
  20741. */
  20742. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20743. /**
  20744. * Gets a number indicating if the current point can be connected to another point
  20745. * @param connectionPoint defines the other connection point
  20746. * @returns a number defining the compatibility state
  20747. */
  20748. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20749. /**
  20750. * Creates a block suitable to be used as an input for this input point.
  20751. * If null is returned, a block based on the point type will be created.
  20752. * @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
  20753. */
  20754. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20755. }
  20756. }
  20757. declare module BABYLON {
  20758. /**
  20759. * Enum defining the type of properties that can be edited in the property pages in the NME
  20760. */
  20761. export enum PropertyTypeForEdition {
  20762. /** property is a boolean */
  20763. Boolean = 0,
  20764. /** property is a float */
  20765. Float = 1,
  20766. /** property is a Vector2 */
  20767. Vector2 = 2,
  20768. /** property is a list of values */
  20769. List = 3
  20770. }
  20771. /**
  20772. * Interface that defines an option in a variable of type list
  20773. */
  20774. export interface IEditablePropertyListOption {
  20775. /** label of the option */
  20776. "label": string;
  20777. /** value of the option */
  20778. "value": number;
  20779. }
  20780. /**
  20781. * Interface that defines the options available for an editable property
  20782. */
  20783. export interface IEditablePropertyOption {
  20784. /** min value */
  20785. "min"?: number;
  20786. /** max value */
  20787. "max"?: number;
  20788. /** notifiers: indicates which actions to take when the property is changed */
  20789. "notifiers"?: {
  20790. /** the material should be rebuilt */
  20791. "rebuild"?: boolean;
  20792. /** the preview should be updated */
  20793. "update"?: boolean;
  20794. };
  20795. /** list of the options for a variable of type list */
  20796. "options"?: IEditablePropertyListOption[];
  20797. }
  20798. /**
  20799. * Interface that describes an editable property
  20800. */
  20801. export interface IPropertyDescriptionForEdition {
  20802. /** name of the property */
  20803. "propertyName": string;
  20804. /** display name of the property */
  20805. "displayName": string;
  20806. /** type of the property */
  20807. "type": PropertyTypeForEdition;
  20808. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20809. "groupName": string;
  20810. /** options for the property */
  20811. "options": IEditablePropertyOption;
  20812. }
  20813. /**
  20814. * Decorator that flags a property in a node material block as being editable
  20815. */
  20816. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20817. }
  20818. declare module BABYLON {
  20819. /**
  20820. * Block used to implement the refraction part of the sub surface module of the PBR material
  20821. */
  20822. export class RefractionBlock extends NodeMaterialBlock {
  20823. /** @hidden */
  20824. _define3DName: string;
  20825. /** @hidden */
  20826. _refractionMatrixName: string;
  20827. /** @hidden */
  20828. _defineLODRefractionAlpha: string;
  20829. /** @hidden */
  20830. _defineLinearSpecularRefraction: string;
  20831. /** @hidden */
  20832. _defineOppositeZ: string;
  20833. /** @hidden */
  20834. _cubeSamplerName: string;
  20835. /** @hidden */
  20836. _2DSamplerName: string;
  20837. /** @hidden */
  20838. _vRefractionMicrosurfaceInfosName: string;
  20839. /** @hidden */
  20840. _vRefractionInfosName: string;
  20841. private _scene;
  20842. /**
  20843. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20844. * Materials half opaque for instance using refraction could benefit from this control.
  20845. */
  20846. linkRefractionWithTransparency: boolean;
  20847. /**
  20848. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20849. */
  20850. invertRefractionY: boolean;
  20851. /**
  20852. * Gets or sets the texture associated with the node
  20853. */
  20854. texture: Nullable<BaseTexture>;
  20855. /**
  20856. * Create a new RefractionBlock
  20857. * @param name defines the block name
  20858. */
  20859. constructor(name: string);
  20860. /**
  20861. * Gets the current class name
  20862. * @returns the class name
  20863. */
  20864. getClassName(): string;
  20865. /**
  20866. * Gets the intensity input component
  20867. */
  20868. get intensity(): NodeMaterialConnectionPoint;
  20869. /**
  20870. * Gets the index of refraction input component
  20871. */
  20872. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20873. /**
  20874. * Gets the tint at distance input component
  20875. */
  20876. get tintAtDistance(): NodeMaterialConnectionPoint;
  20877. /**
  20878. * Gets the view input component
  20879. */
  20880. get view(): NodeMaterialConnectionPoint;
  20881. /**
  20882. * Gets the refraction object output component
  20883. */
  20884. get refraction(): NodeMaterialConnectionPoint;
  20885. /**
  20886. * Returns true if the block has a texture
  20887. */
  20888. get hasTexture(): boolean;
  20889. protected _getTexture(): Nullable<BaseTexture>;
  20890. autoConfigure(material: NodeMaterial): void;
  20891. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20892. isReady(): boolean;
  20893. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20894. /**
  20895. * Gets the main code of the block (fragment side)
  20896. * @param state current state of the node material building
  20897. * @returns the shader code
  20898. */
  20899. getCode(state: NodeMaterialBuildState): string;
  20900. protected _buildBlock(state: NodeMaterialBuildState): this;
  20901. protected _dumpPropertiesCode(): string;
  20902. serialize(): any;
  20903. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20904. }
  20905. }
  20906. declare module BABYLON {
  20907. /**
  20908. * Base block used as input for post process
  20909. */
  20910. export class CurrentScreenBlock extends NodeMaterialBlock {
  20911. private _samplerName;
  20912. private _linearDefineName;
  20913. private _gammaDefineName;
  20914. private _mainUVName;
  20915. private _tempTextureRead;
  20916. /**
  20917. * Gets or sets the texture associated with the node
  20918. */
  20919. texture: Nullable<BaseTexture>;
  20920. /**
  20921. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20922. */
  20923. convertToGammaSpace: boolean;
  20924. /**
  20925. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20926. */
  20927. convertToLinearSpace: boolean;
  20928. /**
  20929. * Create a new CurrentScreenBlock
  20930. * @param name defines the block name
  20931. */
  20932. constructor(name: string);
  20933. /**
  20934. * Gets the current class name
  20935. * @returns the class name
  20936. */
  20937. getClassName(): string;
  20938. /**
  20939. * Gets the uv input component
  20940. */
  20941. get uv(): NodeMaterialConnectionPoint;
  20942. /**
  20943. * Gets the rgba output component
  20944. */
  20945. get rgba(): NodeMaterialConnectionPoint;
  20946. /**
  20947. * Gets the rgb output component
  20948. */
  20949. get rgb(): NodeMaterialConnectionPoint;
  20950. /**
  20951. * Gets the r output component
  20952. */
  20953. get r(): NodeMaterialConnectionPoint;
  20954. /**
  20955. * Gets the g output component
  20956. */
  20957. get g(): NodeMaterialConnectionPoint;
  20958. /**
  20959. * Gets the b output component
  20960. */
  20961. get b(): NodeMaterialConnectionPoint;
  20962. /**
  20963. * Gets the a output component
  20964. */
  20965. get a(): NodeMaterialConnectionPoint;
  20966. /**
  20967. * Initialize the block and prepare the context for build
  20968. * @param state defines the state that will be used for the build
  20969. */
  20970. initialize(state: NodeMaterialBuildState): void;
  20971. get target(): NodeMaterialBlockTargets;
  20972. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20973. isReady(): boolean;
  20974. private _injectVertexCode;
  20975. private _writeTextureRead;
  20976. private _writeOutput;
  20977. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20978. serialize(): any;
  20979. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20980. }
  20981. }
  20982. declare module BABYLON {
  20983. /**
  20984. * Base block used for the particle texture
  20985. */
  20986. export class ParticleTextureBlock extends NodeMaterialBlock {
  20987. private _samplerName;
  20988. private _linearDefineName;
  20989. private _gammaDefineName;
  20990. private _tempTextureRead;
  20991. /**
  20992. * Gets or sets the texture associated with the node
  20993. */
  20994. texture: Nullable<BaseTexture>;
  20995. /**
  20996. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20997. */
  20998. convertToGammaSpace: boolean;
  20999. /**
  21000. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21001. */
  21002. convertToLinearSpace: boolean;
  21003. /**
  21004. * Create a new ParticleTextureBlock
  21005. * @param name defines the block name
  21006. */
  21007. constructor(name: string);
  21008. /**
  21009. * Gets the current class name
  21010. * @returns the class name
  21011. */
  21012. getClassName(): string;
  21013. /**
  21014. * Gets the uv input component
  21015. */
  21016. get uv(): NodeMaterialConnectionPoint;
  21017. /**
  21018. * Gets the rgba output component
  21019. */
  21020. get rgba(): NodeMaterialConnectionPoint;
  21021. /**
  21022. * Gets the rgb output component
  21023. */
  21024. get rgb(): NodeMaterialConnectionPoint;
  21025. /**
  21026. * Gets the r output component
  21027. */
  21028. get r(): NodeMaterialConnectionPoint;
  21029. /**
  21030. * Gets the g output component
  21031. */
  21032. get g(): NodeMaterialConnectionPoint;
  21033. /**
  21034. * Gets the b output component
  21035. */
  21036. get b(): NodeMaterialConnectionPoint;
  21037. /**
  21038. * Gets the a output component
  21039. */
  21040. get a(): NodeMaterialConnectionPoint;
  21041. /**
  21042. * Initialize the block and prepare the context for build
  21043. * @param state defines the state that will be used for the build
  21044. */
  21045. initialize(state: NodeMaterialBuildState): void;
  21046. autoConfigure(material: NodeMaterial): void;
  21047. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21048. isReady(): boolean;
  21049. private _writeOutput;
  21050. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21051. serialize(): any;
  21052. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21053. }
  21054. }
  21055. declare module BABYLON {
  21056. /**
  21057. * Class used to store shared data between 2 NodeMaterialBuildState
  21058. */
  21059. export class NodeMaterialBuildStateSharedData {
  21060. /**
  21061. * Gets the list of emitted varyings
  21062. */
  21063. temps: string[];
  21064. /**
  21065. * Gets the list of emitted varyings
  21066. */
  21067. varyings: string[];
  21068. /**
  21069. * Gets the varying declaration string
  21070. */
  21071. varyingDeclaration: string;
  21072. /**
  21073. * Input blocks
  21074. */
  21075. inputBlocks: InputBlock[];
  21076. /**
  21077. * Input blocks
  21078. */
  21079. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21080. /**
  21081. * Bindable blocks (Blocks that need to set data to the effect)
  21082. */
  21083. bindableBlocks: NodeMaterialBlock[];
  21084. /**
  21085. * List of blocks that can provide a compilation fallback
  21086. */
  21087. blocksWithFallbacks: NodeMaterialBlock[];
  21088. /**
  21089. * List of blocks that can provide a define update
  21090. */
  21091. blocksWithDefines: NodeMaterialBlock[];
  21092. /**
  21093. * List of blocks that can provide a repeatable content
  21094. */
  21095. repeatableContentBlocks: NodeMaterialBlock[];
  21096. /**
  21097. * List of blocks that can provide a dynamic list of uniforms
  21098. */
  21099. dynamicUniformBlocks: NodeMaterialBlock[];
  21100. /**
  21101. * List of blocks that can block the isReady function for the material
  21102. */
  21103. blockingBlocks: NodeMaterialBlock[];
  21104. /**
  21105. * Gets the list of animated inputs
  21106. */
  21107. animatedInputs: InputBlock[];
  21108. /**
  21109. * Build Id used to avoid multiple recompilations
  21110. */
  21111. buildId: number;
  21112. /** List of emitted variables */
  21113. variableNames: {
  21114. [key: string]: number;
  21115. };
  21116. /** List of emitted defines */
  21117. defineNames: {
  21118. [key: string]: number;
  21119. };
  21120. /** Should emit comments? */
  21121. emitComments: boolean;
  21122. /** Emit build activity */
  21123. verbose: boolean;
  21124. /** Gets or sets the hosting scene */
  21125. scene: Scene;
  21126. /**
  21127. * Gets the compilation hints emitted at compilation time
  21128. */
  21129. hints: {
  21130. needWorldViewMatrix: boolean;
  21131. needWorldViewProjectionMatrix: boolean;
  21132. needAlphaBlending: boolean;
  21133. needAlphaTesting: boolean;
  21134. };
  21135. /**
  21136. * List of compilation checks
  21137. */
  21138. checks: {
  21139. emitVertex: boolean;
  21140. emitFragment: boolean;
  21141. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21142. };
  21143. /**
  21144. * Is vertex program allowed to be empty?
  21145. */
  21146. allowEmptyVertexProgram: boolean;
  21147. /** Creates a new shared data */
  21148. constructor();
  21149. /**
  21150. * Emits console errors and exceptions if there is a failing check
  21151. */
  21152. emitErrors(): void;
  21153. }
  21154. }
  21155. declare module BABYLON {
  21156. /**
  21157. * Class used to store node based material build state
  21158. */
  21159. export class NodeMaterialBuildState {
  21160. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21161. supportUniformBuffers: boolean;
  21162. /**
  21163. * Gets the list of emitted attributes
  21164. */
  21165. attributes: string[];
  21166. /**
  21167. * Gets the list of emitted uniforms
  21168. */
  21169. uniforms: string[];
  21170. /**
  21171. * Gets the list of emitted constants
  21172. */
  21173. constants: string[];
  21174. /**
  21175. * Gets the list of emitted samplers
  21176. */
  21177. samplers: string[];
  21178. /**
  21179. * Gets the list of emitted functions
  21180. */
  21181. functions: {
  21182. [key: string]: string;
  21183. };
  21184. /**
  21185. * Gets the list of emitted extensions
  21186. */
  21187. extensions: {
  21188. [key: string]: string;
  21189. };
  21190. /**
  21191. * Gets the target of the compilation state
  21192. */
  21193. target: NodeMaterialBlockTargets;
  21194. /**
  21195. * Gets the list of emitted counters
  21196. */
  21197. counters: {
  21198. [key: string]: number;
  21199. };
  21200. /**
  21201. * Shared data between multiple NodeMaterialBuildState instances
  21202. */
  21203. sharedData: NodeMaterialBuildStateSharedData;
  21204. /** @hidden */
  21205. _vertexState: NodeMaterialBuildState;
  21206. /** @hidden */
  21207. _attributeDeclaration: string;
  21208. /** @hidden */
  21209. _uniformDeclaration: string;
  21210. /** @hidden */
  21211. _constantDeclaration: string;
  21212. /** @hidden */
  21213. _samplerDeclaration: string;
  21214. /** @hidden */
  21215. _varyingTransfer: string;
  21216. /** @hidden */
  21217. _injectAtEnd: string;
  21218. private _repeatableContentAnchorIndex;
  21219. /** @hidden */
  21220. _builtCompilationString: string;
  21221. /**
  21222. * Gets the emitted compilation strings
  21223. */
  21224. compilationString: string;
  21225. /**
  21226. * Finalize the compilation strings
  21227. * @param state defines the current compilation state
  21228. */
  21229. finalize(state: NodeMaterialBuildState): void;
  21230. /** @hidden */
  21231. get _repeatableContentAnchor(): string;
  21232. /** @hidden */
  21233. _getFreeVariableName(prefix: string): string;
  21234. /** @hidden */
  21235. _getFreeDefineName(prefix: string): string;
  21236. /** @hidden */
  21237. _excludeVariableName(name: string): void;
  21238. /** @hidden */
  21239. _emit2DSampler(name: string): void;
  21240. /** @hidden */
  21241. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21242. /** @hidden */
  21243. _emitExtension(name: string, extension: string, define?: string): void;
  21244. /** @hidden */
  21245. _emitFunction(name: string, code: string, comments: string): void;
  21246. /** @hidden */
  21247. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21248. replaceStrings?: {
  21249. search: RegExp;
  21250. replace: string;
  21251. }[];
  21252. repeatKey?: string;
  21253. }): string;
  21254. /** @hidden */
  21255. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21256. repeatKey?: string;
  21257. removeAttributes?: boolean;
  21258. removeUniforms?: boolean;
  21259. removeVaryings?: boolean;
  21260. removeIfDef?: boolean;
  21261. replaceStrings?: {
  21262. search: RegExp;
  21263. replace: string;
  21264. }[];
  21265. }, storeKey?: string): void;
  21266. /** @hidden */
  21267. _registerTempVariable(name: string): boolean;
  21268. /** @hidden */
  21269. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21270. /** @hidden */
  21271. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21272. /** @hidden */
  21273. _emitFloat(value: number): string;
  21274. }
  21275. }
  21276. declare module BABYLON {
  21277. /**
  21278. * Helper class used to generate session unique ID
  21279. */
  21280. export class UniqueIdGenerator {
  21281. private static _UniqueIdCounter;
  21282. /**
  21283. * Gets an unique (relatively to the current scene) Id
  21284. */
  21285. static get UniqueId(): number;
  21286. }
  21287. }
  21288. declare module BABYLON {
  21289. /**
  21290. * Defines a block that can be used inside a node based material
  21291. */
  21292. export class NodeMaterialBlock {
  21293. private _buildId;
  21294. private _buildTarget;
  21295. private _target;
  21296. private _isFinalMerger;
  21297. private _isInput;
  21298. protected _isUnique: boolean;
  21299. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21300. inputsAreExclusive: boolean;
  21301. /** @hidden */
  21302. _codeVariableName: string;
  21303. /** @hidden */
  21304. _inputs: NodeMaterialConnectionPoint[];
  21305. /** @hidden */
  21306. _outputs: NodeMaterialConnectionPoint[];
  21307. /** @hidden */
  21308. _preparationId: number;
  21309. /**
  21310. * Gets or sets the name of the block
  21311. */
  21312. name: string;
  21313. /**
  21314. * Gets or sets the unique id of the node
  21315. */
  21316. uniqueId: number;
  21317. /**
  21318. * Gets or sets the comments associated with this block
  21319. */
  21320. comments: string;
  21321. /**
  21322. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21323. */
  21324. get isUnique(): boolean;
  21325. /**
  21326. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21327. */
  21328. get isFinalMerger(): boolean;
  21329. /**
  21330. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21331. */
  21332. get isInput(): boolean;
  21333. /**
  21334. * Gets or sets the build Id
  21335. */
  21336. get buildId(): number;
  21337. set buildId(value: number);
  21338. /**
  21339. * Gets or sets the target of the block
  21340. */
  21341. get target(): NodeMaterialBlockTargets;
  21342. set target(value: NodeMaterialBlockTargets);
  21343. /**
  21344. * Gets the list of input points
  21345. */
  21346. get inputs(): NodeMaterialConnectionPoint[];
  21347. /** Gets the list of output points */
  21348. get outputs(): NodeMaterialConnectionPoint[];
  21349. /**
  21350. * Find an input by its name
  21351. * @param name defines the name of the input to look for
  21352. * @returns the input or null if not found
  21353. */
  21354. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21355. /**
  21356. * Find an output by its name
  21357. * @param name defines the name of the outputto look for
  21358. * @returns the output or null if not found
  21359. */
  21360. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21361. /**
  21362. * Creates a new NodeMaterialBlock
  21363. * @param name defines the block name
  21364. * @param target defines the target of that block (Vertex by default)
  21365. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21366. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21367. */
  21368. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21369. /**
  21370. * Initialize the block and prepare the context for build
  21371. * @param state defines the state that will be used for the build
  21372. */
  21373. initialize(state: NodeMaterialBuildState): void;
  21374. /**
  21375. * Bind data to effect. Will only be called for blocks with isBindable === true
  21376. * @param effect defines the effect to bind data to
  21377. * @param nodeMaterial defines the hosting NodeMaterial
  21378. * @param mesh defines the mesh that will be rendered
  21379. * @param subMesh defines the submesh that will be rendered
  21380. */
  21381. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21382. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21383. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21384. protected _writeFloat(value: number): string;
  21385. /**
  21386. * Gets the current class name e.g. "NodeMaterialBlock"
  21387. * @returns the class name
  21388. */
  21389. getClassName(): string;
  21390. /**
  21391. * Register a new input. Must be called inside a block constructor
  21392. * @param name defines the connection point name
  21393. * @param type defines the connection point type
  21394. * @param isOptional defines a boolean indicating that this input can be omitted
  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. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21400. /**
  21401. * Register a new output. Must be called inside a block constructor
  21402. * @param name defines the connection point name
  21403. * @param type defines the connection point type
  21404. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21405. * @param point an already created connection point. If not provided, create a new one
  21406. * @returns the current block
  21407. */
  21408. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21409. /**
  21410. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21411. * @param forOutput defines an optional connection point to check compatibility with
  21412. * @returns the first available input or null
  21413. */
  21414. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21415. /**
  21416. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21417. * @param forBlock defines an optional block to check compatibility with
  21418. * @returns the first available input or null
  21419. */
  21420. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21421. /**
  21422. * Gets the sibling of the given output
  21423. * @param current defines the current output
  21424. * @returns the next output in the list or null
  21425. */
  21426. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21427. /**
  21428. * Connect current block with another block
  21429. * @param other defines the block to connect with
  21430. * @param options define the various options to help pick the right connections
  21431. * @returns the current block
  21432. */
  21433. connectTo(other: NodeMaterialBlock, options?: {
  21434. input?: string;
  21435. output?: string;
  21436. outputSwizzle?: string;
  21437. }): this | undefined;
  21438. protected _buildBlock(state: NodeMaterialBuildState): void;
  21439. /**
  21440. * Add uniforms, samplers and uniform buffers at compilation time
  21441. * @param state defines the state to update
  21442. * @param nodeMaterial defines the node material requesting the update
  21443. * @param defines defines the material defines to update
  21444. * @param uniformBuffers defines the list of uniform buffer names
  21445. */
  21446. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21447. /**
  21448. * Add potential fallbacks if shader compilation fails
  21449. * @param mesh defines the mesh to be rendered
  21450. * @param fallbacks defines the current prioritized list of fallbacks
  21451. */
  21452. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21453. /**
  21454. * Initialize defines for shader compilation
  21455. * @param mesh defines the mesh to be rendered
  21456. * @param nodeMaterial defines the node material requesting the update
  21457. * @param defines defines the material defines to update
  21458. * @param useInstances specifies that instances should be used
  21459. */
  21460. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21461. /**
  21462. * Update defines for shader compilation
  21463. * @param mesh defines the mesh to be rendered
  21464. * @param nodeMaterial defines the node material requesting the update
  21465. * @param defines defines the material defines to update
  21466. * @param useInstances specifies that instances should be used
  21467. */
  21468. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21469. /**
  21470. * Lets the block try to connect some inputs automatically
  21471. * @param material defines the hosting NodeMaterial
  21472. */
  21473. autoConfigure(material: NodeMaterial): void;
  21474. /**
  21475. * Function called when a block is declared as repeatable content generator
  21476. * @param vertexShaderState defines the current compilation state for the vertex shader
  21477. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21478. * @param mesh defines the mesh to be rendered
  21479. * @param defines defines the material defines to update
  21480. */
  21481. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21482. /**
  21483. * Checks if the block is ready
  21484. * @param mesh defines the mesh to be rendered
  21485. * @param nodeMaterial defines the node material requesting the update
  21486. * @param defines defines the material defines to update
  21487. * @param useInstances specifies that instances should be used
  21488. * @returns true if the block is ready
  21489. */
  21490. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21491. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21492. private _processBuild;
  21493. /**
  21494. * Compile the current node and generate the shader code
  21495. * @param state defines the current compilation state (uniforms, samplers, current string)
  21496. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21497. * @returns true if already built
  21498. */
  21499. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21500. protected _inputRename(name: string): string;
  21501. protected _outputRename(name: string): string;
  21502. protected _dumpPropertiesCode(): string;
  21503. /** @hidden */
  21504. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21505. /** @hidden */
  21506. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21507. /**
  21508. * Clone the current block to a new identical block
  21509. * @param scene defines the hosting scene
  21510. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21511. * @returns a copy of the current block
  21512. */
  21513. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21514. /**
  21515. * Serializes this block in a JSON representation
  21516. * @returns the serialized block object
  21517. */
  21518. serialize(): any;
  21519. /** @hidden */
  21520. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21521. private _deserializePortDisplayNames;
  21522. /**
  21523. * Release resources
  21524. */
  21525. dispose(): void;
  21526. }
  21527. }
  21528. declare module BABYLON {
  21529. /**
  21530. * Base class of materials working in push mode in babylon JS
  21531. * @hidden
  21532. */
  21533. export class PushMaterial extends Material {
  21534. protected _activeEffect: Effect;
  21535. protected _normalMatrix: Matrix;
  21536. /**
  21537. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  21538. * This means that the material can keep using a previous shader while a new one is being compiled.
  21539. * This is mostly used when shader parallel compilation is supported (true by default)
  21540. */
  21541. allowShaderHotSwapping: boolean;
  21542. constructor(name: string, scene: Scene);
  21543. getEffect(): Effect;
  21544. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21545. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21546. /**
  21547. * Binds the given world matrix to the active effect
  21548. *
  21549. * @param world the matrix to bind
  21550. */
  21551. bindOnlyWorldMatrix(world: Matrix): void;
  21552. /**
  21553. * Binds the given normal matrix to the active effect
  21554. *
  21555. * @param normalMatrix the matrix to bind
  21556. */
  21557. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21558. bind(world: Matrix, mesh?: Mesh): void;
  21559. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21560. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21561. }
  21562. }
  21563. declare module BABYLON {
  21564. /**
  21565. * Root class for all node material optimizers
  21566. */
  21567. export class NodeMaterialOptimizer {
  21568. /**
  21569. * Function used to optimize a NodeMaterial graph
  21570. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21571. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21572. */
  21573. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21574. }
  21575. }
  21576. declare module BABYLON {
  21577. /**
  21578. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21579. */
  21580. export class TransformBlock extends NodeMaterialBlock {
  21581. /**
  21582. * Defines the value to use to complement W value to transform it to a Vector4
  21583. */
  21584. complementW: number;
  21585. /**
  21586. * Defines the value to use to complement z value to transform it to a Vector4
  21587. */
  21588. complementZ: number;
  21589. /**
  21590. * Creates a new TransformBlock
  21591. * @param name defines the block name
  21592. */
  21593. constructor(name: string);
  21594. /**
  21595. * Gets the current class name
  21596. * @returns the class name
  21597. */
  21598. getClassName(): string;
  21599. /**
  21600. * Gets the vector input
  21601. */
  21602. get vector(): NodeMaterialConnectionPoint;
  21603. /**
  21604. * Gets the output component
  21605. */
  21606. get output(): NodeMaterialConnectionPoint;
  21607. /**
  21608. * Gets the xyz output component
  21609. */
  21610. get xyz(): NodeMaterialConnectionPoint;
  21611. /**
  21612. * Gets the matrix transform input
  21613. */
  21614. get transform(): NodeMaterialConnectionPoint;
  21615. protected _buildBlock(state: NodeMaterialBuildState): this;
  21616. serialize(): any;
  21617. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21618. protected _dumpPropertiesCode(): string;
  21619. }
  21620. }
  21621. declare module BABYLON {
  21622. /**
  21623. * Block used to output the vertex position
  21624. */
  21625. export class VertexOutputBlock extends NodeMaterialBlock {
  21626. /**
  21627. * Creates a new VertexOutputBlock
  21628. * @param name defines the block name
  21629. */
  21630. constructor(name: string);
  21631. /**
  21632. * Gets the current class name
  21633. * @returns the class name
  21634. */
  21635. getClassName(): string;
  21636. /**
  21637. * Gets the vector input component
  21638. */
  21639. get vector(): NodeMaterialConnectionPoint;
  21640. protected _buildBlock(state: NodeMaterialBuildState): this;
  21641. }
  21642. }
  21643. declare module BABYLON {
  21644. /**
  21645. * Block used to output the final color
  21646. */
  21647. export class FragmentOutputBlock extends NodeMaterialBlock {
  21648. /**
  21649. * Create a new FragmentOutputBlock
  21650. * @param name defines the block name
  21651. */
  21652. constructor(name: string);
  21653. /**
  21654. * Gets the current class name
  21655. * @returns the class name
  21656. */
  21657. getClassName(): string;
  21658. /**
  21659. * Gets the rgba input component
  21660. */
  21661. get rgba(): NodeMaterialConnectionPoint;
  21662. /**
  21663. * Gets the rgb input component
  21664. */
  21665. get rgb(): NodeMaterialConnectionPoint;
  21666. /**
  21667. * Gets the a input component
  21668. */
  21669. get a(): NodeMaterialConnectionPoint;
  21670. protected _buildBlock(state: NodeMaterialBuildState): this;
  21671. }
  21672. }
  21673. declare module BABYLON {
  21674. /**
  21675. * Block used for the particle ramp gradient section
  21676. */
  21677. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21678. /**
  21679. * Create a new ParticleRampGradientBlock
  21680. * @param name defines the block name
  21681. */
  21682. constructor(name: string);
  21683. /**
  21684. * Gets the current class name
  21685. * @returns the class name
  21686. */
  21687. getClassName(): string;
  21688. /**
  21689. * Gets the color input component
  21690. */
  21691. get color(): NodeMaterialConnectionPoint;
  21692. /**
  21693. * Gets the rampColor output component
  21694. */
  21695. get rampColor(): NodeMaterialConnectionPoint;
  21696. /**
  21697. * Initialize the block and prepare the context for build
  21698. * @param state defines the state that will be used for the build
  21699. */
  21700. initialize(state: NodeMaterialBuildState): void;
  21701. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21702. }
  21703. }
  21704. declare module BABYLON {
  21705. /**
  21706. * Block used for the particle blend multiply section
  21707. */
  21708. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21709. /**
  21710. * Create a new ParticleBlendMultiplyBlock
  21711. * @param name defines the block name
  21712. */
  21713. constructor(name: string);
  21714. /**
  21715. * Gets the current class name
  21716. * @returns the class name
  21717. */
  21718. getClassName(): string;
  21719. /**
  21720. * Gets the color input component
  21721. */
  21722. get color(): NodeMaterialConnectionPoint;
  21723. /**
  21724. * Gets the alphaTexture input component
  21725. */
  21726. get alphaTexture(): NodeMaterialConnectionPoint;
  21727. /**
  21728. * Gets the alphaColor input component
  21729. */
  21730. get alphaColor(): NodeMaterialConnectionPoint;
  21731. /**
  21732. * Gets the blendColor output component
  21733. */
  21734. get blendColor(): NodeMaterialConnectionPoint;
  21735. /**
  21736. * Initialize the block and prepare the context for build
  21737. * @param state defines the state that will be used for the build
  21738. */
  21739. initialize(state: NodeMaterialBuildState): void;
  21740. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21741. }
  21742. }
  21743. declare module BABYLON {
  21744. /**
  21745. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21746. */
  21747. export class VectorMergerBlock extends NodeMaterialBlock {
  21748. /**
  21749. * Create a new VectorMergerBlock
  21750. * @param name defines the block name
  21751. */
  21752. constructor(name: string);
  21753. /**
  21754. * Gets the current class name
  21755. * @returns the class name
  21756. */
  21757. getClassName(): string;
  21758. /**
  21759. * Gets the xyz component (input)
  21760. */
  21761. get xyzIn(): NodeMaterialConnectionPoint;
  21762. /**
  21763. * Gets the xy component (input)
  21764. */
  21765. get xyIn(): NodeMaterialConnectionPoint;
  21766. /**
  21767. * Gets the x component (input)
  21768. */
  21769. get x(): NodeMaterialConnectionPoint;
  21770. /**
  21771. * Gets the y component (input)
  21772. */
  21773. get y(): NodeMaterialConnectionPoint;
  21774. /**
  21775. * Gets the z component (input)
  21776. */
  21777. get z(): NodeMaterialConnectionPoint;
  21778. /**
  21779. * Gets the w component (input)
  21780. */
  21781. get w(): NodeMaterialConnectionPoint;
  21782. /**
  21783. * Gets the xyzw component (output)
  21784. */
  21785. get xyzw(): NodeMaterialConnectionPoint;
  21786. /**
  21787. * Gets the xyz component (output)
  21788. */
  21789. get xyzOut(): NodeMaterialConnectionPoint;
  21790. /**
  21791. * Gets the xy component (output)
  21792. */
  21793. get xyOut(): NodeMaterialConnectionPoint;
  21794. /**
  21795. * Gets the xy component (output)
  21796. * @deprecated Please use xyOut instead.
  21797. */
  21798. get xy(): NodeMaterialConnectionPoint;
  21799. /**
  21800. * Gets the xyz component (output)
  21801. * @deprecated Please use xyzOut instead.
  21802. */
  21803. get xyz(): NodeMaterialConnectionPoint;
  21804. protected _buildBlock(state: NodeMaterialBuildState): this;
  21805. }
  21806. }
  21807. declare module BABYLON {
  21808. /**
  21809. * Block used to remap a float from a range to a new one
  21810. */
  21811. export class RemapBlock extends NodeMaterialBlock {
  21812. /**
  21813. * Gets or sets the source range
  21814. */
  21815. sourceRange: Vector2;
  21816. /**
  21817. * Gets or sets the target range
  21818. */
  21819. targetRange: Vector2;
  21820. /**
  21821. * Creates a new RemapBlock
  21822. * @param name defines the block name
  21823. */
  21824. constructor(name: string);
  21825. /**
  21826. * Gets the current class name
  21827. * @returns the class name
  21828. */
  21829. getClassName(): string;
  21830. /**
  21831. * Gets the input component
  21832. */
  21833. get input(): NodeMaterialConnectionPoint;
  21834. /**
  21835. * Gets the source min input component
  21836. */
  21837. get sourceMin(): NodeMaterialConnectionPoint;
  21838. /**
  21839. * Gets the source max input component
  21840. */
  21841. get sourceMax(): NodeMaterialConnectionPoint;
  21842. /**
  21843. * Gets the target min input component
  21844. */
  21845. get targetMin(): NodeMaterialConnectionPoint;
  21846. /**
  21847. * Gets the target max input component
  21848. */
  21849. get targetMax(): NodeMaterialConnectionPoint;
  21850. /**
  21851. * Gets the output component
  21852. */
  21853. get output(): NodeMaterialConnectionPoint;
  21854. protected _buildBlock(state: NodeMaterialBuildState): this;
  21855. protected _dumpPropertiesCode(): string;
  21856. serialize(): any;
  21857. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21858. }
  21859. }
  21860. declare module BABYLON {
  21861. /**
  21862. * Block used to multiply 2 values
  21863. */
  21864. export class MultiplyBlock extends NodeMaterialBlock {
  21865. /**
  21866. * Creates a new MultiplyBlock
  21867. * @param name defines the block name
  21868. */
  21869. constructor(name: string);
  21870. /**
  21871. * Gets the current class name
  21872. * @returns the class name
  21873. */
  21874. getClassName(): string;
  21875. /**
  21876. * Gets the left operand input component
  21877. */
  21878. get left(): NodeMaterialConnectionPoint;
  21879. /**
  21880. * Gets the right operand input component
  21881. */
  21882. get right(): NodeMaterialConnectionPoint;
  21883. /**
  21884. * Gets the output component
  21885. */
  21886. get output(): NodeMaterialConnectionPoint;
  21887. protected _buildBlock(state: NodeMaterialBuildState): this;
  21888. }
  21889. }
  21890. declare module BABYLON {
  21891. /**
  21892. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21893. */
  21894. export class ColorSplitterBlock extends NodeMaterialBlock {
  21895. /**
  21896. * Create a new ColorSplitterBlock
  21897. * @param name defines the block name
  21898. */
  21899. constructor(name: string);
  21900. /**
  21901. * Gets the current class name
  21902. * @returns the class name
  21903. */
  21904. getClassName(): string;
  21905. /**
  21906. * Gets the rgba component (input)
  21907. */
  21908. get rgba(): NodeMaterialConnectionPoint;
  21909. /**
  21910. * Gets the rgb component (input)
  21911. */
  21912. get rgbIn(): NodeMaterialConnectionPoint;
  21913. /**
  21914. * Gets the rgb component (output)
  21915. */
  21916. get rgbOut(): NodeMaterialConnectionPoint;
  21917. /**
  21918. * Gets the r component (output)
  21919. */
  21920. get r(): NodeMaterialConnectionPoint;
  21921. /**
  21922. * Gets the g component (output)
  21923. */
  21924. get g(): NodeMaterialConnectionPoint;
  21925. /**
  21926. * Gets the b component (output)
  21927. */
  21928. get b(): NodeMaterialConnectionPoint;
  21929. /**
  21930. * Gets the a component (output)
  21931. */
  21932. get a(): NodeMaterialConnectionPoint;
  21933. protected _inputRename(name: string): string;
  21934. protected _outputRename(name: string): string;
  21935. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21936. }
  21937. }
  21938. declare module BABYLON {
  21939. /**
  21940. * Interface used to configure the node material editor
  21941. */
  21942. export interface INodeMaterialEditorOptions {
  21943. /** Define the URl to load node editor script */
  21944. editorURL?: string;
  21945. }
  21946. /** @hidden */
  21947. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21948. NORMAL: boolean;
  21949. TANGENT: boolean;
  21950. UV1: boolean;
  21951. /** BONES */
  21952. NUM_BONE_INFLUENCERS: number;
  21953. BonesPerMesh: number;
  21954. BONETEXTURE: boolean;
  21955. /** MORPH TARGETS */
  21956. MORPHTARGETS: boolean;
  21957. MORPHTARGETS_NORMAL: boolean;
  21958. MORPHTARGETS_TANGENT: boolean;
  21959. MORPHTARGETS_UV: boolean;
  21960. NUM_MORPH_INFLUENCERS: number;
  21961. /** IMAGE PROCESSING */
  21962. IMAGEPROCESSING: boolean;
  21963. VIGNETTE: boolean;
  21964. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21965. VIGNETTEBLENDMODEOPAQUE: boolean;
  21966. TONEMAPPING: boolean;
  21967. TONEMAPPING_ACES: boolean;
  21968. CONTRAST: boolean;
  21969. EXPOSURE: boolean;
  21970. COLORCURVES: boolean;
  21971. COLORGRADING: boolean;
  21972. COLORGRADING3D: boolean;
  21973. SAMPLER3DGREENDEPTH: boolean;
  21974. SAMPLER3DBGRMAP: boolean;
  21975. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21976. /** MISC. */
  21977. BUMPDIRECTUV: number;
  21978. constructor();
  21979. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  21980. }
  21981. /**
  21982. * Class used to configure NodeMaterial
  21983. */
  21984. export interface INodeMaterialOptions {
  21985. /**
  21986. * Defines if blocks should emit comments
  21987. */
  21988. emitComments: boolean;
  21989. }
  21990. /**
  21991. * Class used to create a node based material built by assembling shader blocks
  21992. */
  21993. export class NodeMaterial extends PushMaterial {
  21994. private static _BuildIdGenerator;
  21995. private _options;
  21996. private _vertexCompilationState;
  21997. private _fragmentCompilationState;
  21998. private _sharedData;
  21999. private _buildId;
  22000. private _buildWasSuccessful;
  22001. private _cachedWorldViewMatrix;
  22002. private _cachedWorldViewProjectionMatrix;
  22003. private _optimizers;
  22004. private _animationFrame;
  22005. /** Define the Url to load node editor script */
  22006. static EditorURL: string;
  22007. /** Define the Url to load snippets */
  22008. static SnippetUrl: string;
  22009. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22010. static IgnoreTexturesAtLoadTime: boolean;
  22011. private BJSNODEMATERIALEDITOR;
  22012. /** Get the inspector from bundle or global */
  22013. private _getGlobalNodeMaterialEditor;
  22014. /**
  22015. * Snippet ID if the material was created from the snippet server
  22016. */
  22017. snippetId: string;
  22018. /**
  22019. * Gets or sets data used by visual editor
  22020. * @see https://nme.babylonjs.com
  22021. */
  22022. editorData: any;
  22023. /**
  22024. * 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)
  22025. */
  22026. ignoreAlpha: boolean;
  22027. /**
  22028. * Defines the maximum number of lights that can be used in the material
  22029. */
  22030. maxSimultaneousLights: number;
  22031. /**
  22032. * Observable raised when the material is built
  22033. */
  22034. onBuildObservable: Observable<NodeMaterial>;
  22035. /**
  22036. * Gets or sets the root nodes of the material vertex shader
  22037. */
  22038. _vertexOutputNodes: NodeMaterialBlock[];
  22039. /**
  22040. * Gets or sets the root nodes of the material fragment (pixel) shader
  22041. */
  22042. _fragmentOutputNodes: NodeMaterialBlock[];
  22043. /** Gets or sets options to control the node material overall behavior */
  22044. get options(): INodeMaterialOptions;
  22045. set options(options: INodeMaterialOptions);
  22046. /**
  22047. * Default configuration related to image processing available in the standard Material.
  22048. */
  22049. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22050. /**
  22051. * Gets the image processing configuration used either in this material.
  22052. */
  22053. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22054. /**
  22055. * Sets the Default image processing configuration used either in the this material.
  22056. *
  22057. * If sets to null, the scene one is in use.
  22058. */
  22059. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22060. /**
  22061. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22062. */
  22063. attachedBlocks: NodeMaterialBlock[];
  22064. /**
  22065. * Specifies the mode of the node material
  22066. * @hidden
  22067. */
  22068. _mode: NodeMaterialModes;
  22069. /**
  22070. * Gets the mode property
  22071. */
  22072. get mode(): NodeMaterialModes;
  22073. /**
  22074. * Create a new node based material
  22075. * @param name defines the material name
  22076. * @param scene defines the hosting scene
  22077. * @param options defines creation option
  22078. */
  22079. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22080. /**
  22081. * Gets the current class name of the material e.g. "NodeMaterial"
  22082. * @returns the class name
  22083. */
  22084. getClassName(): string;
  22085. /**
  22086. * Keep track of the image processing observer to allow dispose and replace.
  22087. */
  22088. private _imageProcessingObserver;
  22089. /**
  22090. * Attaches a new image processing configuration to the Standard Material.
  22091. * @param configuration
  22092. */
  22093. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22094. /**
  22095. * Get a block by its name
  22096. * @param name defines the name of the block to retrieve
  22097. * @returns the required block or null if not found
  22098. */
  22099. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22100. /**
  22101. * Get a block by its name
  22102. * @param predicate defines the predicate used to find the good candidate
  22103. * @returns the required block or null if not found
  22104. */
  22105. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22106. /**
  22107. * Get an input block by its name
  22108. * @param predicate defines the predicate used to find the good candidate
  22109. * @returns the required input block or null if not found
  22110. */
  22111. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22112. /**
  22113. * Gets the list of input blocks attached to this material
  22114. * @returns an array of InputBlocks
  22115. */
  22116. getInputBlocks(): InputBlock[];
  22117. /**
  22118. * Adds a new optimizer to the list of optimizers
  22119. * @param optimizer defines the optimizers to add
  22120. * @returns the current material
  22121. */
  22122. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22123. /**
  22124. * Remove an optimizer from the list of optimizers
  22125. * @param optimizer defines the optimizers to remove
  22126. * @returns the current material
  22127. */
  22128. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22129. /**
  22130. * Add a new block to the list of output nodes
  22131. * @param node defines the node to add
  22132. * @returns the current material
  22133. */
  22134. addOutputNode(node: NodeMaterialBlock): this;
  22135. /**
  22136. * Remove a block from the list of root nodes
  22137. * @param node defines the node to remove
  22138. * @returns the current material
  22139. */
  22140. removeOutputNode(node: NodeMaterialBlock): this;
  22141. private _addVertexOutputNode;
  22142. private _removeVertexOutputNode;
  22143. private _addFragmentOutputNode;
  22144. private _removeFragmentOutputNode;
  22145. /**
  22146. * Specifies if the material will require alpha blending
  22147. * @returns a boolean specifying if alpha blending is needed
  22148. */
  22149. needAlphaBlending(): boolean;
  22150. /**
  22151. * Specifies if this material should be rendered in alpha test mode
  22152. * @returns a boolean specifying if an alpha test is needed.
  22153. */
  22154. needAlphaTesting(): boolean;
  22155. private _initializeBlock;
  22156. private _resetDualBlocks;
  22157. /**
  22158. * Remove a block from the current node material
  22159. * @param block defines the block to remove
  22160. */
  22161. removeBlock(block: NodeMaterialBlock): void;
  22162. /**
  22163. * Build the material and generates the inner effect
  22164. * @param verbose defines if the build should log activity
  22165. */
  22166. build(verbose?: boolean): void;
  22167. /**
  22168. * Runs an otpimization phase to try to improve the shader code
  22169. */
  22170. optimize(): void;
  22171. private _prepareDefinesForAttributes;
  22172. /**
  22173. * Create a post process from the material
  22174. * @param camera The camera to apply the render pass to.
  22175. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22177. * @param engine The engine which the post process will be applied. (default: current engine)
  22178. * @param reusable If the post process can be reused on the same frame. (default: false)
  22179. * @param textureType Type of textures used when performing the post process. (default: 0)
  22180. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22181. * @returns the post process created
  22182. */
  22183. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22184. /**
  22185. * Create the post process effect from the material
  22186. * @param postProcess The post process to create the effect for
  22187. */
  22188. createEffectForPostProcess(postProcess: PostProcess): void;
  22189. private _createEffectOrPostProcess;
  22190. private _createEffectForParticles;
  22191. /**
  22192. * Create the effect to be used as the custom effect for a particle system
  22193. * @param particleSystem Particle system to create the effect for
  22194. * @param onCompiled defines a function to call when the effect creation is successful
  22195. * @param onError defines a function to call when the effect creation has failed
  22196. */
  22197. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22198. private _processDefines;
  22199. /**
  22200. * Get if the submesh is ready to be used and all its information available.
  22201. * Child classes can use it to update shaders
  22202. * @param mesh defines the mesh to check
  22203. * @param subMesh defines which submesh to check
  22204. * @param useInstances specifies that instances should be used
  22205. * @returns a boolean indicating that the submesh is ready or not
  22206. */
  22207. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22208. /**
  22209. * Get a string representing the shaders built by the current node graph
  22210. */
  22211. get compiledShaders(): string;
  22212. /**
  22213. * Binds the world matrix to the material
  22214. * @param world defines the world transformation matrix
  22215. */
  22216. bindOnlyWorldMatrix(world: Matrix): void;
  22217. /**
  22218. * Binds the submesh to this material by preparing the effect and shader to draw
  22219. * @param world defines the world transformation matrix
  22220. * @param mesh defines the mesh containing the submesh
  22221. * @param subMesh defines the submesh to bind the material to
  22222. */
  22223. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22224. /**
  22225. * Gets the active textures from the material
  22226. * @returns an array of textures
  22227. */
  22228. getActiveTextures(): BaseTexture[];
  22229. /**
  22230. * Gets the list of texture blocks
  22231. * @returns an array of texture blocks
  22232. */
  22233. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22234. /**
  22235. * Specifies if the material uses a texture
  22236. * @param texture defines the texture to check against the material
  22237. * @returns a boolean specifying if the material uses the texture
  22238. */
  22239. hasTexture(texture: BaseTexture): boolean;
  22240. /**
  22241. * Disposes the material
  22242. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22243. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22244. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22245. */
  22246. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22247. /** Creates the node editor window. */
  22248. private _createNodeEditor;
  22249. /**
  22250. * Launch the node material editor
  22251. * @param config Define the configuration of the editor
  22252. * @return a promise fulfilled when the node editor is visible
  22253. */
  22254. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22255. /**
  22256. * Clear the current material
  22257. */
  22258. clear(): void;
  22259. /**
  22260. * Clear the current material and set it to a default state
  22261. */
  22262. setToDefault(): void;
  22263. /**
  22264. * Clear the current material and set it to a default state for post process
  22265. */
  22266. setToDefaultPostProcess(): void;
  22267. /**
  22268. * Clear the current material and set it to a default state for particle
  22269. */
  22270. setToDefaultParticle(): void;
  22271. /**
  22272. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22273. * @param url defines the url to load from
  22274. * @returns a promise that will fullfil when the material is fully loaded
  22275. */
  22276. loadAsync(url: string): Promise<void>;
  22277. private _gatherBlocks;
  22278. /**
  22279. * Generate a string containing the code declaration required to create an equivalent of this material
  22280. * @returns a string
  22281. */
  22282. generateCode(): string;
  22283. /**
  22284. * Serializes this material in a JSON representation
  22285. * @returns the serialized material object
  22286. */
  22287. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22288. private _restoreConnections;
  22289. /**
  22290. * Clear the current graph and load a new one from a serialization object
  22291. * @param source defines the JSON representation of the material
  22292. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22293. */
  22294. loadFromSerialization(source: any, rootUrl?: string): void;
  22295. /**
  22296. * Makes a duplicate of the current material.
  22297. * @param name - name to use for the new material.
  22298. */
  22299. clone(name: string): NodeMaterial;
  22300. /**
  22301. * Creates a node material from parsed material data
  22302. * @param source defines the JSON representation of the material
  22303. * @param scene defines the hosting scene
  22304. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22305. * @returns a new node material
  22306. */
  22307. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22308. /**
  22309. * Creates a node material from a snippet saved in a remote file
  22310. * @param name defines the name of the material to create
  22311. * @param url defines the url to load from
  22312. * @param scene defines the hosting scene
  22313. * @returns a promise that will resolve to the new node material
  22314. */
  22315. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22316. /**
  22317. * Creates a node material from a snippet saved by the node material editor
  22318. * @param snippetId defines the snippet to load
  22319. * @param scene defines the hosting scene
  22320. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22321. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22322. * @returns a promise that will resolve to the new node material
  22323. */
  22324. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22325. /**
  22326. * Creates a new node material set to default basic configuration
  22327. * @param name defines the name of the material
  22328. * @param scene defines the hosting scene
  22329. * @returns a new NodeMaterial
  22330. */
  22331. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22332. }
  22333. }
  22334. declare module BABYLON {
  22335. /**
  22336. * Size options for a post process
  22337. */
  22338. export type PostProcessOptions = {
  22339. width: number;
  22340. height: number;
  22341. };
  22342. /**
  22343. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22344. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22345. */
  22346. export class PostProcess {
  22347. /** Name of the PostProcess. */
  22348. name: string;
  22349. /**
  22350. * Gets or sets the unique id of the post process
  22351. */
  22352. uniqueId: number;
  22353. /**
  22354. * Width of the texture to apply the post process on
  22355. */
  22356. width: number;
  22357. /**
  22358. * Height of the texture to apply the post process on
  22359. */
  22360. height: number;
  22361. /**
  22362. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22363. */
  22364. nodeMaterialSource: Nullable<NodeMaterial>;
  22365. /**
  22366. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22367. * @hidden
  22368. */
  22369. _outputTexture: Nullable<InternalTexture>;
  22370. /**
  22371. * Sampling mode used by the shader
  22372. * See https://doc.babylonjs.com/classes/3.1/texture
  22373. */
  22374. renderTargetSamplingMode: number;
  22375. /**
  22376. * Clear color to use when screen clearing
  22377. */
  22378. clearColor: Color4;
  22379. /**
  22380. * If the buffer needs to be cleared before applying the post process. (default: true)
  22381. * Should be set to false if shader will overwrite all previous pixels.
  22382. */
  22383. autoClear: boolean;
  22384. /**
  22385. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22386. */
  22387. alphaMode: number;
  22388. /**
  22389. * Sets the setAlphaBlendConstants of the babylon engine
  22390. */
  22391. alphaConstants: Color4;
  22392. /**
  22393. * Animations to be used for the post processing
  22394. */
  22395. animations: Animation[];
  22396. /**
  22397. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22398. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22399. */
  22400. enablePixelPerfectMode: boolean;
  22401. /**
  22402. * Force the postprocess to be applied without taking in account viewport
  22403. */
  22404. forceFullscreenViewport: boolean;
  22405. /**
  22406. * List of inspectable custom properties (used by the Inspector)
  22407. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22408. */
  22409. inspectableCustomProperties: IInspectable[];
  22410. /**
  22411. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22412. *
  22413. * | Value | Type | Description |
  22414. * | ----- | ----------------------------------- | ----------- |
  22415. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22416. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22417. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22418. *
  22419. */
  22420. scaleMode: number;
  22421. /**
  22422. * Force textures to be a power of two (default: false)
  22423. */
  22424. alwaysForcePOT: boolean;
  22425. private _samples;
  22426. /**
  22427. * Number of sample textures (default: 1)
  22428. */
  22429. get samples(): number;
  22430. set samples(n: number);
  22431. /**
  22432. * Modify the scale of the post process to be the same as the viewport (default: false)
  22433. */
  22434. adaptScaleToCurrentViewport: boolean;
  22435. private _camera;
  22436. private _scene;
  22437. private _engine;
  22438. private _options;
  22439. private _reusable;
  22440. private _textureType;
  22441. private _textureFormat;
  22442. /**
  22443. * Smart array of input and output textures for the post process.
  22444. * @hidden
  22445. */
  22446. _textures: SmartArray<InternalTexture>;
  22447. /**
  22448. * The index in _textures that corresponds to the output texture.
  22449. * @hidden
  22450. */
  22451. _currentRenderTextureInd: number;
  22452. private _effect;
  22453. private _samplers;
  22454. private _fragmentUrl;
  22455. private _vertexUrl;
  22456. private _parameters;
  22457. private _scaleRatio;
  22458. protected _indexParameters: any;
  22459. private _shareOutputWithPostProcess;
  22460. private _texelSize;
  22461. private _forcedOutputTexture;
  22462. /**
  22463. * Returns the fragment url or shader name used in the post process.
  22464. * @returns the fragment url or name in the shader store.
  22465. */
  22466. getEffectName(): string;
  22467. /**
  22468. * An event triggered when the postprocess is activated.
  22469. */
  22470. onActivateObservable: Observable<Camera>;
  22471. private _onActivateObserver;
  22472. /**
  22473. * A function that is added to the onActivateObservable
  22474. */
  22475. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22476. /**
  22477. * An event triggered when the postprocess changes its size.
  22478. */
  22479. onSizeChangedObservable: Observable<PostProcess>;
  22480. private _onSizeChangedObserver;
  22481. /**
  22482. * A function that is added to the onSizeChangedObservable
  22483. */
  22484. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22485. /**
  22486. * An event triggered when the postprocess applies its effect.
  22487. */
  22488. onApplyObservable: Observable<Effect>;
  22489. private _onApplyObserver;
  22490. /**
  22491. * A function that is added to the onApplyObservable
  22492. */
  22493. set onApply(callback: (effect: Effect) => void);
  22494. /**
  22495. * An event triggered before rendering the postprocess
  22496. */
  22497. onBeforeRenderObservable: Observable<Effect>;
  22498. private _onBeforeRenderObserver;
  22499. /**
  22500. * A function that is added to the onBeforeRenderObservable
  22501. */
  22502. set onBeforeRender(callback: (effect: Effect) => void);
  22503. /**
  22504. * An event triggered after rendering the postprocess
  22505. */
  22506. onAfterRenderObservable: Observable<Effect>;
  22507. private _onAfterRenderObserver;
  22508. /**
  22509. * A function that is added to the onAfterRenderObservable
  22510. */
  22511. set onAfterRender(callback: (efect: Effect) => void);
  22512. /**
  22513. * 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
  22514. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22515. */
  22516. get inputTexture(): InternalTexture;
  22517. set inputTexture(value: InternalTexture);
  22518. /**
  22519. * Gets the camera which post process is applied to.
  22520. * @returns The camera the post process is applied to.
  22521. */
  22522. getCamera(): Camera;
  22523. /**
  22524. * Gets the texel size of the postprocess.
  22525. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22526. */
  22527. get texelSize(): Vector2;
  22528. /**
  22529. * Creates a new instance PostProcess
  22530. * @param name The name of the PostProcess.
  22531. * @param fragmentUrl The url of the fragment shader to be used.
  22532. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22533. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22534. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22535. * @param camera The camera to apply the render pass to.
  22536. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22537. * @param engine The engine which the post process will be applied. (default: current engine)
  22538. * @param reusable If the post process can be reused on the same frame. (default: false)
  22539. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22540. * @param textureType Type of textures used when performing the post process. (default: 0)
  22541. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22542. * @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
  22543. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22544. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22545. */
  22546. constructor(
  22547. /** Name of the PostProcess. */
  22548. 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);
  22549. /**
  22550. * Gets a string idenfifying the name of the class
  22551. * @returns "PostProcess" string
  22552. */
  22553. getClassName(): string;
  22554. /**
  22555. * Gets the engine which this post process belongs to.
  22556. * @returns The engine the post process was enabled with.
  22557. */
  22558. getEngine(): Engine;
  22559. /**
  22560. * The effect that is created when initializing the post process.
  22561. * @returns The created effect corresponding the the postprocess.
  22562. */
  22563. getEffect(): Effect;
  22564. /**
  22565. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22566. * @param postProcess The post process to share the output with.
  22567. * @returns This post process.
  22568. */
  22569. shareOutputWith(postProcess: PostProcess): PostProcess;
  22570. /**
  22571. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22572. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22573. */
  22574. useOwnOutput(): void;
  22575. /**
  22576. * Updates the effect with the current post process compile time values and recompiles the shader.
  22577. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22578. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22579. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22580. * @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
  22581. * @param onCompiled Called when the shader has been compiled.
  22582. * @param onError Called if there is an error when compiling a shader.
  22583. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22584. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22585. */
  22586. 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;
  22587. /**
  22588. * The post process is reusable if it can be used multiple times within one frame.
  22589. * @returns If the post process is reusable
  22590. */
  22591. isReusable(): boolean;
  22592. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22593. markTextureDirty(): void;
  22594. /**
  22595. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22596. * 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.
  22597. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22598. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22599. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22600. * @returns The target texture that was bound to be written to.
  22601. */
  22602. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22603. /**
  22604. * If the post process is supported.
  22605. */
  22606. get isSupported(): boolean;
  22607. /**
  22608. * The aspect ratio of the output texture.
  22609. */
  22610. get aspectRatio(): number;
  22611. /**
  22612. * Get a value indicating if the post-process is ready to be used
  22613. * @returns true if the post-process is ready (shader is compiled)
  22614. */
  22615. isReady(): boolean;
  22616. /**
  22617. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22618. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22619. */
  22620. apply(): Nullable<Effect>;
  22621. private _disposeTextures;
  22622. /**
  22623. * Disposes the post process.
  22624. * @param camera The camera to dispose the post process on.
  22625. */
  22626. dispose(camera?: Camera): void;
  22627. }
  22628. }
  22629. declare module BABYLON {
  22630. /** @hidden */
  22631. export var kernelBlurVaryingDeclaration: {
  22632. name: string;
  22633. shader: string;
  22634. };
  22635. }
  22636. declare module BABYLON {
  22637. /** @hidden */
  22638. export var kernelBlurFragment: {
  22639. name: string;
  22640. shader: string;
  22641. };
  22642. }
  22643. declare module BABYLON {
  22644. /** @hidden */
  22645. export var kernelBlurFragment2: {
  22646. name: string;
  22647. shader: string;
  22648. };
  22649. }
  22650. declare module BABYLON {
  22651. /** @hidden */
  22652. export var kernelBlurPixelShader: {
  22653. name: string;
  22654. shader: string;
  22655. };
  22656. }
  22657. declare module BABYLON {
  22658. /** @hidden */
  22659. export var kernelBlurVertex: {
  22660. name: string;
  22661. shader: string;
  22662. };
  22663. }
  22664. declare module BABYLON {
  22665. /** @hidden */
  22666. export var kernelBlurVertexShader: {
  22667. name: string;
  22668. shader: string;
  22669. };
  22670. }
  22671. declare module BABYLON {
  22672. /**
  22673. * The Blur Post Process which blurs an image based on a kernel and direction.
  22674. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22675. */
  22676. export class BlurPostProcess extends PostProcess {
  22677. /** The direction in which to blur the image. */
  22678. direction: Vector2;
  22679. private blockCompilation;
  22680. protected _kernel: number;
  22681. protected _idealKernel: number;
  22682. protected _packedFloat: boolean;
  22683. private _staticDefines;
  22684. /**
  22685. * Sets the length in pixels of the blur sample region
  22686. */
  22687. set kernel(v: number);
  22688. /**
  22689. * Gets the length in pixels of the blur sample region
  22690. */
  22691. get kernel(): number;
  22692. /**
  22693. * Sets wether or not the blur needs to unpack/repack floats
  22694. */
  22695. set packedFloat(v: boolean);
  22696. /**
  22697. * Gets wether or not the blur is unpacking/repacking floats
  22698. */
  22699. get packedFloat(): boolean;
  22700. /**
  22701. * Creates a new instance BlurPostProcess
  22702. * @param name The name of the effect.
  22703. * @param direction The direction in which to blur the image.
  22704. * @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.
  22705. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22706. * @param camera The camera to apply the render pass to.
  22707. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22708. * @param engine The engine which the post process will be applied. (default: current engine)
  22709. * @param reusable If the post process can be reused on the same frame. (default: false)
  22710. * @param textureType Type of textures used when performing the post process. (default: 0)
  22711. * @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)
  22712. */
  22713. constructor(name: string,
  22714. /** The direction in which to blur the image. */
  22715. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22716. /**
  22717. * Updates the effect with the current post process compile time values and recompiles the shader.
  22718. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22719. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22720. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22721. * @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
  22722. * @param onCompiled Called when the shader has been compiled.
  22723. * @param onError Called if there is an error when compiling a shader.
  22724. */
  22725. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22726. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22727. /**
  22728. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22729. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22730. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22731. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22732. * The gaps between physical kernels are compensated for in the weighting of the samples
  22733. * @param idealKernel Ideal blur kernel.
  22734. * @return Nearest best kernel.
  22735. */
  22736. protected _nearestBestKernel(idealKernel: number): number;
  22737. /**
  22738. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22739. * @param x The point on the Gaussian distribution to sample.
  22740. * @return the value of the Gaussian function at x.
  22741. */
  22742. protected _gaussianWeight(x: number): number;
  22743. /**
  22744. * Generates a string that can be used as a floating point number in GLSL.
  22745. * @param x Value to print.
  22746. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22747. * @return GLSL float string.
  22748. */
  22749. protected _glslFloat(x: number, decimalFigures?: number): string;
  22750. }
  22751. }
  22752. declare module BABYLON {
  22753. /**
  22754. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22755. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22756. * You can then easily use it as a reflectionTexture on a flat surface.
  22757. * In case the surface is not a plane, please consider relying on reflection probes.
  22758. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22759. */
  22760. export class MirrorTexture extends RenderTargetTexture {
  22761. private scene;
  22762. /**
  22763. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22764. * 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.
  22765. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22766. */
  22767. mirrorPlane: Plane;
  22768. /**
  22769. * Define the blur ratio used to blur the reflection if needed.
  22770. */
  22771. set blurRatio(value: number);
  22772. get blurRatio(): number;
  22773. /**
  22774. * Define the adaptive blur kernel used to blur the reflection if needed.
  22775. * This will autocompute the closest best match for the `blurKernel`
  22776. */
  22777. set adaptiveBlurKernel(value: number);
  22778. /**
  22779. * Define the blur kernel used to blur the reflection if needed.
  22780. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22781. */
  22782. set blurKernel(value: number);
  22783. /**
  22784. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22785. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22786. */
  22787. set blurKernelX(value: number);
  22788. get blurKernelX(): number;
  22789. /**
  22790. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22791. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22792. */
  22793. set blurKernelY(value: number);
  22794. get blurKernelY(): number;
  22795. private _autoComputeBlurKernel;
  22796. protected _onRatioRescale(): void;
  22797. private _updateGammaSpace;
  22798. private _imageProcessingConfigChangeObserver;
  22799. private _transformMatrix;
  22800. private _mirrorMatrix;
  22801. private _savedViewMatrix;
  22802. private _blurX;
  22803. private _blurY;
  22804. private _adaptiveBlurKernel;
  22805. private _blurKernelX;
  22806. private _blurKernelY;
  22807. private _blurRatio;
  22808. /**
  22809. * Instantiates a Mirror Texture.
  22810. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22811. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22812. * You can then easily use it as a reflectionTexture on a flat surface.
  22813. * In case the surface is not a plane, please consider relying on reflection probes.
  22814. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22815. * @param name
  22816. * @param size
  22817. * @param scene
  22818. * @param generateMipMaps
  22819. * @param type
  22820. * @param samplingMode
  22821. * @param generateDepthBuffer
  22822. */
  22823. constructor(name: string, size: number | {
  22824. width: number;
  22825. height: number;
  22826. } | {
  22827. ratio: number;
  22828. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22829. private _preparePostProcesses;
  22830. /**
  22831. * Clone the mirror texture.
  22832. * @returns the cloned texture
  22833. */
  22834. clone(): MirrorTexture;
  22835. /**
  22836. * Serialize the texture to a JSON representation you could use in Parse later on
  22837. * @returns the serialized JSON representation
  22838. */
  22839. serialize(): any;
  22840. /**
  22841. * Dispose the texture and release its associated resources.
  22842. */
  22843. dispose(): void;
  22844. }
  22845. }
  22846. declare module BABYLON {
  22847. /**
  22848. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22849. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22850. */
  22851. export class Texture extends BaseTexture {
  22852. /**
  22853. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22854. */
  22855. static SerializeBuffers: boolean;
  22856. /** @hidden */
  22857. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22858. /** @hidden */
  22859. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22860. /** @hidden */
  22861. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22862. /** nearest is mag = nearest and min = nearest and mip = linear */
  22863. static readonly NEAREST_SAMPLINGMODE: number;
  22864. /** nearest is mag = nearest and min = nearest and mip = linear */
  22865. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22866. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22867. static readonly BILINEAR_SAMPLINGMODE: number;
  22868. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22869. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22870. /** Trilinear is mag = linear and min = linear and mip = linear */
  22871. static readonly TRILINEAR_SAMPLINGMODE: number;
  22872. /** Trilinear is mag = linear and min = linear and mip = linear */
  22873. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22874. /** mag = nearest and min = nearest and mip = nearest */
  22875. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22876. /** mag = nearest and min = linear and mip = nearest */
  22877. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22878. /** mag = nearest and min = linear and mip = linear */
  22879. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22880. /** mag = nearest and min = linear and mip = none */
  22881. static readonly NEAREST_LINEAR: number;
  22882. /** mag = nearest and min = nearest and mip = none */
  22883. static readonly NEAREST_NEAREST: number;
  22884. /** mag = linear and min = nearest and mip = nearest */
  22885. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22886. /** mag = linear and min = nearest and mip = linear */
  22887. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22888. /** mag = linear and min = linear and mip = none */
  22889. static readonly LINEAR_LINEAR: number;
  22890. /** mag = linear and min = nearest and mip = none */
  22891. static readonly LINEAR_NEAREST: number;
  22892. /** Explicit coordinates mode */
  22893. static readonly EXPLICIT_MODE: number;
  22894. /** Spherical coordinates mode */
  22895. static readonly SPHERICAL_MODE: number;
  22896. /** Planar coordinates mode */
  22897. static readonly PLANAR_MODE: number;
  22898. /** Cubic coordinates mode */
  22899. static readonly CUBIC_MODE: number;
  22900. /** Projection coordinates mode */
  22901. static readonly PROJECTION_MODE: number;
  22902. /** Inverse Cubic coordinates mode */
  22903. static readonly SKYBOX_MODE: number;
  22904. /** Inverse Cubic coordinates mode */
  22905. static readonly INVCUBIC_MODE: number;
  22906. /** Equirectangular coordinates mode */
  22907. static readonly EQUIRECTANGULAR_MODE: number;
  22908. /** Equirectangular Fixed coordinates mode */
  22909. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22910. /** Equirectangular Fixed Mirrored coordinates mode */
  22911. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22912. /** Texture is not repeating outside of 0..1 UVs */
  22913. static readonly CLAMP_ADDRESSMODE: number;
  22914. /** Texture is repeating outside of 0..1 UVs */
  22915. static readonly WRAP_ADDRESSMODE: number;
  22916. /** Texture is repeating and mirrored */
  22917. static readonly MIRROR_ADDRESSMODE: number;
  22918. /**
  22919. * 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
  22920. */
  22921. static UseSerializedUrlIfAny: boolean;
  22922. /**
  22923. * Define the url of the texture.
  22924. */
  22925. url: Nullable<string>;
  22926. /**
  22927. * Define an offset on the texture to offset the u coordinates of the UVs
  22928. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22929. */
  22930. uOffset: number;
  22931. /**
  22932. * Define an offset on the texture to offset the v coordinates of the UVs
  22933. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22934. */
  22935. vOffset: number;
  22936. /**
  22937. * Define an offset on the texture to scale the u coordinates of the UVs
  22938. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22939. */
  22940. uScale: number;
  22941. /**
  22942. * Define an offset on the texture to scale the v coordinates of the UVs
  22943. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22944. */
  22945. vScale: number;
  22946. /**
  22947. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22948. * @see http://doc.babylonjs.com/how_to/more_materials
  22949. */
  22950. uAng: number;
  22951. /**
  22952. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22953. * @see http://doc.babylonjs.com/how_to/more_materials
  22954. */
  22955. vAng: number;
  22956. /**
  22957. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22958. * @see http://doc.babylonjs.com/how_to/more_materials
  22959. */
  22960. wAng: number;
  22961. /**
  22962. * Defines the center of rotation (U)
  22963. */
  22964. uRotationCenter: number;
  22965. /**
  22966. * Defines the center of rotation (V)
  22967. */
  22968. vRotationCenter: number;
  22969. /**
  22970. * Defines the center of rotation (W)
  22971. */
  22972. wRotationCenter: number;
  22973. /**
  22974. * Are mip maps generated for this texture or not.
  22975. */
  22976. get noMipmap(): boolean;
  22977. /**
  22978. * List of inspectable custom properties (used by the Inspector)
  22979. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22980. */
  22981. inspectableCustomProperties: Nullable<IInspectable[]>;
  22982. private _noMipmap;
  22983. /** @hidden */
  22984. _invertY: boolean;
  22985. private _rowGenerationMatrix;
  22986. private _cachedTextureMatrix;
  22987. private _projectionModeMatrix;
  22988. private _t0;
  22989. private _t1;
  22990. private _t2;
  22991. private _cachedUOffset;
  22992. private _cachedVOffset;
  22993. private _cachedUScale;
  22994. private _cachedVScale;
  22995. private _cachedUAng;
  22996. private _cachedVAng;
  22997. private _cachedWAng;
  22998. private _cachedProjectionMatrixId;
  22999. private _cachedCoordinatesMode;
  23000. /** @hidden */
  23001. protected _initialSamplingMode: number;
  23002. /** @hidden */
  23003. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23004. private _deleteBuffer;
  23005. protected _format: Nullable<number>;
  23006. private _delayedOnLoad;
  23007. private _delayedOnError;
  23008. private _mimeType?;
  23009. /**
  23010. * Observable triggered once the texture has been loaded.
  23011. */
  23012. onLoadObservable: Observable<Texture>;
  23013. protected _isBlocking: boolean;
  23014. /**
  23015. * Is the texture preventing material to render while loading.
  23016. * If false, a default texture will be used instead of the loading one during the preparation step.
  23017. */
  23018. set isBlocking(value: boolean);
  23019. get isBlocking(): boolean;
  23020. /**
  23021. * Get the current sampling mode associated with the texture.
  23022. */
  23023. get samplingMode(): number;
  23024. /**
  23025. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23026. */
  23027. get invertY(): boolean;
  23028. /**
  23029. * Instantiates a new texture.
  23030. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23031. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23032. * @param url defines the url of the picture to load as a texture
  23033. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23034. * @param noMipmap defines if the texture will require mip maps or not
  23035. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23036. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23037. * @param onLoad defines a callback triggered when the texture has been loaded
  23038. * @param onError defines a callback triggered when an error occurred during the loading session
  23039. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23040. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23041. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23042. * @param mimeType defines an optional mime type information
  23043. */
  23044. 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);
  23045. /**
  23046. * Update the url (and optional buffer) of this texture if url was null during construction.
  23047. * @param url the url of the texture
  23048. * @param buffer the buffer of the texture (defaults to null)
  23049. * @param onLoad callback called when the texture is loaded (defaults to null)
  23050. */
  23051. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23052. /**
  23053. * Finish the loading sequence of a texture flagged as delayed load.
  23054. * @hidden
  23055. */
  23056. delayLoad(): void;
  23057. private _prepareRowForTextureGeneration;
  23058. /**
  23059. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23060. * @returns the transform matrix of the texture.
  23061. */
  23062. getTextureMatrix(uBase?: number): Matrix;
  23063. /**
  23064. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23065. * @returns The reflection texture transform
  23066. */
  23067. getReflectionTextureMatrix(): Matrix;
  23068. /**
  23069. * Clones the texture.
  23070. * @returns the cloned texture
  23071. */
  23072. clone(): Texture;
  23073. /**
  23074. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23075. * @returns The JSON representation of the texture
  23076. */
  23077. serialize(): any;
  23078. /**
  23079. * Get the current class name of the texture useful for serialization or dynamic coding.
  23080. * @returns "Texture"
  23081. */
  23082. getClassName(): string;
  23083. /**
  23084. * Dispose the texture and release its associated resources.
  23085. */
  23086. dispose(): void;
  23087. /**
  23088. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23089. * @param parsedTexture Define the JSON representation of the texture
  23090. * @param scene Define the scene the parsed texture should be instantiated in
  23091. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23092. * @returns The parsed texture if successful
  23093. */
  23094. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23095. /**
  23096. * Creates a texture from its base 64 representation.
  23097. * @param data Define the base64 payload without the data: prefix
  23098. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23099. * @param scene Define the scene the texture should belong to
  23100. * @param noMipmap Forces the texture to not create mip map information if true
  23101. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23102. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23103. * @param onLoad define a callback triggered when the texture has been loaded
  23104. * @param onError define a callback triggered when an error occurred during the loading session
  23105. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23106. * @returns the created texture
  23107. */
  23108. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23109. /**
  23110. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23111. * @param data Define the base64 payload without the data: prefix
  23112. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23113. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23114. * @param scene Define the scene the texture should belong to
  23115. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23116. * @param noMipmap Forces the texture to not create mip map information if true
  23117. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23118. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23119. * @param onLoad define a callback triggered when the texture has been loaded
  23120. * @param onError define a callback triggered when an error occurred during the loading session
  23121. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23122. * @returns the created texture
  23123. */
  23124. 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;
  23125. }
  23126. }
  23127. declare module BABYLON {
  23128. /**
  23129. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23130. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23131. */
  23132. export class PostProcessManager {
  23133. private _scene;
  23134. private _indexBuffer;
  23135. private _vertexBuffers;
  23136. /**
  23137. * Creates a new instance PostProcess
  23138. * @param scene The scene that the post process is associated with.
  23139. */
  23140. constructor(scene: Scene);
  23141. private _prepareBuffers;
  23142. private _buildIndexBuffer;
  23143. /**
  23144. * Rebuilds the vertex buffers of the manager.
  23145. * @hidden
  23146. */
  23147. _rebuild(): void;
  23148. /**
  23149. * Prepares a frame to be run through a post process.
  23150. * @param sourceTexture The input texture to the post procesess. (default: null)
  23151. * @param postProcesses An array of post processes to be run. (default: null)
  23152. * @returns True if the post processes were able to be run.
  23153. * @hidden
  23154. */
  23155. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23156. /**
  23157. * Manually render a set of post processes to a texture.
  23158. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23159. * @param postProcesses An array of post processes to be run.
  23160. * @param targetTexture The target texture to render to.
  23161. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23162. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23163. * @param lodLevel defines which lod of the texture to render to
  23164. */
  23165. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23166. /**
  23167. * Finalize the result of the output of the postprocesses.
  23168. * @param doNotPresent If true the result will not be displayed to the screen.
  23169. * @param targetTexture The target texture to render to.
  23170. * @param faceIndex The index of the face to bind the target texture to.
  23171. * @param postProcesses The array of post processes to render.
  23172. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23173. * @hidden
  23174. */
  23175. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23176. /**
  23177. * Disposes of the post process manager.
  23178. */
  23179. dispose(): void;
  23180. }
  23181. }
  23182. declare module BABYLON {
  23183. /**
  23184. * This Helps creating a texture that will be created from a camera in your scene.
  23185. * It is basically a dynamic texture that could be used to create special effects for instance.
  23186. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23187. */
  23188. export class RenderTargetTexture extends Texture {
  23189. isCube: boolean;
  23190. /**
  23191. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23192. */
  23193. static readonly REFRESHRATE_RENDER_ONCE: number;
  23194. /**
  23195. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23196. */
  23197. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23198. /**
  23199. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23200. * the central point of your effect and can save a lot of performances.
  23201. */
  23202. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23203. /**
  23204. * Use this predicate to dynamically define the list of mesh you want to render.
  23205. * If set, the renderList property will be overwritten.
  23206. */
  23207. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23208. private _renderList;
  23209. /**
  23210. * Use this list to define the list of mesh you want to render.
  23211. */
  23212. get renderList(): Nullable<Array<AbstractMesh>>;
  23213. set renderList(value: Nullable<Array<AbstractMesh>>);
  23214. /**
  23215. * Use this function to overload the renderList array at rendering time.
  23216. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23217. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23218. * the cube (if the RTT is a cube, else layerOrFace=0).
  23219. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23220. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23221. * hold dummy elements!
  23222. */
  23223. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23224. private _hookArray;
  23225. /**
  23226. * Define if particles should be rendered in your texture.
  23227. */
  23228. renderParticles: boolean;
  23229. /**
  23230. * Define if sprites should be rendered in your texture.
  23231. */
  23232. renderSprites: boolean;
  23233. /**
  23234. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23235. */
  23236. coordinatesMode: number;
  23237. /**
  23238. * Define the camera used to render the texture.
  23239. */
  23240. activeCamera: Nullable<Camera>;
  23241. /**
  23242. * Override the mesh isReady function with your own one.
  23243. */
  23244. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23245. /**
  23246. * Override the render function of the texture with your own one.
  23247. */
  23248. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23249. /**
  23250. * Define if camera post processes should be use while rendering the texture.
  23251. */
  23252. useCameraPostProcesses: boolean;
  23253. /**
  23254. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23255. */
  23256. ignoreCameraViewport: boolean;
  23257. private _postProcessManager;
  23258. private _postProcesses;
  23259. private _resizeObserver;
  23260. /**
  23261. * An event triggered when the texture is unbind.
  23262. */
  23263. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23264. /**
  23265. * An event triggered when the texture is unbind.
  23266. */
  23267. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23268. private _onAfterUnbindObserver;
  23269. /**
  23270. * Set a after unbind callback in the texture.
  23271. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23272. */
  23273. set onAfterUnbind(callback: () => void);
  23274. /**
  23275. * An event triggered before rendering the texture
  23276. */
  23277. onBeforeRenderObservable: Observable<number>;
  23278. private _onBeforeRenderObserver;
  23279. /**
  23280. * Set a before render callback in the texture.
  23281. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23282. */
  23283. set onBeforeRender(callback: (faceIndex: number) => void);
  23284. /**
  23285. * An event triggered after rendering the texture
  23286. */
  23287. onAfterRenderObservable: Observable<number>;
  23288. private _onAfterRenderObserver;
  23289. /**
  23290. * Set a after render callback in the texture.
  23291. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23292. */
  23293. set onAfterRender(callback: (faceIndex: number) => void);
  23294. /**
  23295. * An event triggered after the texture clear
  23296. */
  23297. onClearObservable: Observable<Engine>;
  23298. private _onClearObserver;
  23299. /**
  23300. * Set a clear callback in the texture.
  23301. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23302. */
  23303. set onClear(callback: (Engine: Engine) => void);
  23304. /**
  23305. * An event triggered when the texture is resized.
  23306. */
  23307. onResizeObservable: Observable<RenderTargetTexture>;
  23308. /**
  23309. * Define the clear color of the Render Target if it should be different from the scene.
  23310. */
  23311. clearColor: Color4;
  23312. protected _size: number | {
  23313. width: number;
  23314. height: number;
  23315. layers?: number;
  23316. };
  23317. protected _initialSizeParameter: number | {
  23318. width: number;
  23319. height: number;
  23320. } | {
  23321. ratio: number;
  23322. };
  23323. protected _sizeRatio: Nullable<number>;
  23324. /** @hidden */
  23325. _generateMipMaps: boolean;
  23326. protected _renderingManager: RenderingManager;
  23327. /** @hidden */
  23328. _waitingRenderList: string[];
  23329. protected _doNotChangeAspectRatio: boolean;
  23330. protected _currentRefreshId: number;
  23331. protected _refreshRate: number;
  23332. protected _textureMatrix: Matrix;
  23333. protected _samples: number;
  23334. protected _renderTargetOptions: RenderTargetCreationOptions;
  23335. /**
  23336. * Gets render target creation options that were used.
  23337. */
  23338. get renderTargetOptions(): RenderTargetCreationOptions;
  23339. protected _onRatioRescale(): void;
  23340. /**
  23341. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23342. * It must define where the camera used to render the texture is set
  23343. */
  23344. boundingBoxPosition: Vector3;
  23345. private _boundingBoxSize;
  23346. /**
  23347. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23348. * When defined, the cubemap will switch to local mode
  23349. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23350. * @example https://www.babylonjs-playground.com/#RNASML
  23351. */
  23352. set boundingBoxSize(value: Vector3);
  23353. get boundingBoxSize(): Vector3;
  23354. /**
  23355. * In case the RTT has been created with a depth texture, get the associated
  23356. * depth texture.
  23357. * Otherwise, return null.
  23358. */
  23359. get depthStencilTexture(): Nullable<InternalTexture>;
  23360. /**
  23361. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23362. * or used a shadow, depth texture...
  23363. * @param name The friendly name of the texture
  23364. * @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)
  23365. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23366. * @param generateMipMaps True if mip maps need to be generated after render.
  23367. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23368. * @param type The type of the buffer in the RTT (int, half float, float...)
  23369. * @param isCube True if a cube texture needs to be created
  23370. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23371. * @param generateDepthBuffer True to generate a depth buffer
  23372. * @param generateStencilBuffer True to generate a stencil buffer
  23373. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23374. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23375. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23376. */
  23377. constructor(name: string, size: number | {
  23378. width: number;
  23379. height: number;
  23380. layers?: number;
  23381. } | {
  23382. ratio: number;
  23383. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23384. /**
  23385. * Creates a depth stencil texture.
  23386. * This is only available in WebGL 2 or with the depth texture extension available.
  23387. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23388. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23389. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23390. */
  23391. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23392. private _processSizeParameter;
  23393. /**
  23394. * Define the number of samples to use in case of MSAA.
  23395. * It defaults to one meaning no MSAA has been enabled.
  23396. */
  23397. get samples(): number;
  23398. set samples(value: number);
  23399. /**
  23400. * Resets the refresh counter of the texture and start bak from scratch.
  23401. * Could be useful to regenerate the texture if it is setup to render only once.
  23402. */
  23403. resetRefreshCounter(): void;
  23404. /**
  23405. * Define the refresh rate of the texture or the rendering frequency.
  23406. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23407. */
  23408. get refreshRate(): number;
  23409. set refreshRate(value: number);
  23410. /**
  23411. * Adds a post process to the render target rendering passes.
  23412. * @param postProcess define the post process to add
  23413. */
  23414. addPostProcess(postProcess: PostProcess): void;
  23415. /**
  23416. * Clear all the post processes attached to the render target
  23417. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23418. */
  23419. clearPostProcesses(dispose?: boolean): void;
  23420. /**
  23421. * Remove one of the post process from the list of attached post processes to the texture
  23422. * @param postProcess define the post process to remove from the list
  23423. */
  23424. removePostProcess(postProcess: PostProcess): void;
  23425. /** @hidden */
  23426. _shouldRender(): boolean;
  23427. /**
  23428. * Gets the actual render size of the texture.
  23429. * @returns the width of the render size
  23430. */
  23431. getRenderSize(): number;
  23432. /**
  23433. * Gets the actual render width of the texture.
  23434. * @returns the width of the render size
  23435. */
  23436. getRenderWidth(): number;
  23437. /**
  23438. * Gets the actual render height of the texture.
  23439. * @returns the height of the render size
  23440. */
  23441. getRenderHeight(): number;
  23442. /**
  23443. * Gets the actual number of layers of the texture.
  23444. * @returns the number of layers
  23445. */
  23446. getRenderLayers(): number;
  23447. /**
  23448. * Get if the texture can be rescaled or not.
  23449. */
  23450. get canRescale(): boolean;
  23451. /**
  23452. * Resize the texture using a ratio.
  23453. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23454. */
  23455. scale(ratio: number): void;
  23456. /**
  23457. * Get the texture reflection matrix used to rotate/transform the reflection.
  23458. * @returns the reflection matrix
  23459. */
  23460. getReflectionTextureMatrix(): Matrix;
  23461. /**
  23462. * Resize the texture to a new desired size.
  23463. * Be carrefull as it will recreate all the data in the new texture.
  23464. * @param size Define the new size. It can be:
  23465. * - a number for squared texture,
  23466. * - an object containing { width: number, height: number }
  23467. * - or an object containing a ratio { ratio: number }
  23468. */
  23469. resize(size: number | {
  23470. width: number;
  23471. height: number;
  23472. } | {
  23473. ratio: number;
  23474. }): void;
  23475. private _defaultRenderListPrepared;
  23476. /**
  23477. * Renders all the objects from the render list into the texture.
  23478. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23479. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23480. */
  23481. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23482. private _bestReflectionRenderTargetDimension;
  23483. private _prepareRenderingManager;
  23484. /**
  23485. * @hidden
  23486. * @param faceIndex face index to bind to if this is a cubetexture
  23487. * @param layer defines the index of the texture to bind in the array
  23488. */
  23489. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23490. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23491. private renderToTarget;
  23492. /**
  23493. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23494. * This allowed control for front to back rendering or reversly depending of the special needs.
  23495. *
  23496. * @param renderingGroupId The rendering group id corresponding to its index
  23497. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23498. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23499. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23500. */
  23501. 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;
  23502. /**
  23503. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23504. *
  23505. * @param renderingGroupId The rendering group id corresponding to its index
  23506. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23507. */
  23508. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23509. /**
  23510. * Clones the texture.
  23511. * @returns the cloned texture
  23512. */
  23513. clone(): RenderTargetTexture;
  23514. /**
  23515. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23516. * @returns The JSON representation of the texture
  23517. */
  23518. serialize(): any;
  23519. /**
  23520. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23521. */
  23522. disposeFramebufferObjects(): void;
  23523. /**
  23524. * Dispose the texture and release its associated resources.
  23525. */
  23526. dispose(): void;
  23527. /** @hidden */
  23528. _rebuild(): void;
  23529. /**
  23530. * Clear the info related to rendering groups preventing retention point in material dispose.
  23531. */
  23532. freeRenderingGroups(): void;
  23533. /**
  23534. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23535. * @returns the view count
  23536. */
  23537. getViewCount(): number;
  23538. }
  23539. }
  23540. declare module BABYLON {
  23541. /**
  23542. * Class used to manipulate GUIDs
  23543. */
  23544. export class GUID {
  23545. /**
  23546. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23547. * Be aware Math.random() could cause collisions, but:
  23548. * "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"
  23549. * @returns a pseudo random id
  23550. */
  23551. static RandomId(): string;
  23552. }
  23553. }
  23554. declare module BABYLON {
  23555. /**
  23556. * Options to be used when creating a shadow depth material
  23557. */
  23558. export interface IIOptionShadowDepthMaterial {
  23559. /** Variables in the vertex shader code that need to have their names remapped.
  23560. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23561. * "var_name" should be either: worldPos or vNormalW
  23562. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23563. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23564. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23565. */
  23566. remappedVariables?: string[];
  23567. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23568. standalone?: boolean;
  23569. }
  23570. /**
  23571. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23572. */
  23573. export class ShadowDepthWrapper {
  23574. private _scene;
  23575. private _options?;
  23576. private _baseMaterial;
  23577. private _onEffectCreatedObserver;
  23578. private _subMeshToEffect;
  23579. private _subMeshToDepthEffect;
  23580. private _meshes;
  23581. /** @hidden */
  23582. _matriceNames: any;
  23583. /** Gets the standalone status of the wrapper */
  23584. get standalone(): boolean;
  23585. /** Gets the base material the wrapper is built upon */
  23586. get baseMaterial(): Material;
  23587. /**
  23588. * Instantiate a new shadow depth wrapper.
  23589. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23590. * generate the shadow depth map. For more information, please refer to the documentation:
  23591. * https://doc.babylonjs.com/babylon101/shadows
  23592. * @param baseMaterial Material to wrap
  23593. * @param scene Define the scene the material belongs to
  23594. * @param options Options used to create the wrapper
  23595. */
  23596. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23597. /**
  23598. * Gets the effect to use to generate the depth map
  23599. * @param subMesh subMesh to get the effect for
  23600. * @param shadowGenerator shadow generator to get the effect for
  23601. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23602. */
  23603. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23604. /**
  23605. * Specifies that the submesh is ready to be used for depth rendering
  23606. * @param subMesh submesh to check
  23607. * @param defines the list of defines to take into account when checking the effect
  23608. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23609. * @param useInstances specifies that instances should be used
  23610. * @returns a boolean indicating that the submesh is ready or not
  23611. */
  23612. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23613. /**
  23614. * Disposes the resources
  23615. */
  23616. dispose(): void;
  23617. private _makeEffect;
  23618. }
  23619. }
  23620. declare module BABYLON {
  23621. /**
  23622. * Options for compiling materials.
  23623. */
  23624. export interface IMaterialCompilationOptions {
  23625. /**
  23626. * Defines whether clip planes are enabled.
  23627. */
  23628. clipPlane: boolean;
  23629. /**
  23630. * Defines whether instances are enabled.
  23631. */
  23632. useInstances: boolean;
  23633. }
  23634. /**
  23635. * Options passed when calling customShaderNameResolve
  23636. */
  23637. export interface ICustomShaderNameResolveOptions {
  23638. /**
  23639. * 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
  23640. */
  23641. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23642. }
  23643. /**
  23644. * Base class for the main features of a material in Babylon.js
  23645. */
  23646. export class Material implements IAnimatable {
  23647. /**
  23648. * Returns the triangle fill mode
  23649. */
  23650. static readonly TriangleFillMode: number;
  23651. /**
  23652. * Returns the wireframe mode
  23653. */
  23654. static readonly WireFrameFillMode: number;
  23655. /**
  23656. * Returns the point fill mode
  23657. */
  23658. static readonly PointFillMode: number;
  23659. /**
  23660. * Returns the point list draw mode
  23661. */
  23662. static readonly PointListDrawMode: number;
  23663. /**
  23664. * Returns the line list draw mode
  23665. */
  23666. static readonly LineListDrawMode: number;
  23667. /**
  23668. * Returns the line loop draw mode
  23669. */
  23670. static readonly LineLoopDrawMode: number;
  23671. /**
  23672. * Returns the line strip draw mode
  23673. */
  23674. static readonly LineStripDrawMode: number;
  23675. /**
  23676. * Returns the triangle strip draw mode
  23677. */
  23678. static readonly TriangleStripDrawMode: number;
  23679. /**
  23680. * Returns the triangle fan draw mode
  23681. */
  23682. static readonly TriangleFanDrawMode: number;
  23683. /**
  23684. * Stores the clock-wise side orientation
  23685. */
  23686. static readonly ClockWiseSideOrientation: number;
  23687. /**
  23688. * Stores the counter clock-wise side orientation
  23689. */
  23690. static readonly CounterClockWiseSideOrientation: number;
  23691. /**
  23692. * The dirty texture flag value
  23693. */
  23694. static readonly TextureDirtyFlag: number;
  23695. /**
  23696. * The dirty light flag value
  23697. */
  23698. static readonly LightDirtyFlag: number;
  23699. /**
  23700. * The dirty fresnel flag value
  23701. */
  23702. static readonly FresnelDirtyFlag: number;
  23703. /**
  23704. * The dirty attribute flag value
  23705. */
  23706. static readonly AttributesDirtyFlag: number;
  23707. /**
  23708. * The dirty misc flag value
  23709. */
  23710. static readonly MiscDirtyFlag: number;
  23711. /**
  23712. * The all dirty flag value
  23713. */
  23714. static readonly AllDirtyFlag: number;
  23715. /**
  23716. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23717. */
  23718. static readonly MATERIAL_OPAQUE: number;
  23719. /**
  23720. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23721. */
  23722. static readonly MATERIAL_ALPHATEST: number;
  23723. /**
  23724. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23725. */
  23726. static readonly MATERIAL_ALPHABLEND: number;
  23727. /**
  23728. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23729. * They are also discarded below the alpha cutoff threshold to improve performances.
  23730. */
  23731. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23732. /**
  23733. * Custom callback helping to override the default shader used in the material.
  23734. */
  23735. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23736. /**
  23737. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23738. */
  23739. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23740. /**
  23741. * The ID of the material
  23742. */
  23743. id: string;
  23744. /**
  23745. * Gets or sets the unique id of the material
  23746. */
  23747. uniqueId: number;
  23748. /**
  23749. * The name of the material
  23750. */
  23751. name: string;
  23752. /**
  23753. * Gets or sets user defined metadata
  23754. */
  23755. metadata: any;
  23756. /**
  23757. * For internal use only. Please do not use.
  23758. */
  23759. reservedDataStore: any;
  23760. /**
  23761. * Specifies if the ready state should be checked on each call
  23762. */
  23763. checkReadyOnEveryCall: boolean;
  23764. /**
  23765. * Specifies if the ready state should be checked once
  23766. */
  23767. checkReadyOnlyOnce: boolean;
  23768. /**
  23769. * The state of the material
  23770. */
  23771. state: string;
  23772. /**
  23773. * The alpha value of the material
  23774. */
  23775. protected _alpha: number;
  23776. /**
  23777. * List of inspectable custom properties (used by the Inspector)
  23778. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23779. */
  23780. inspectableCustomProperties: IInspectable[];
  23781. /**
  23782. * Sets the alpha value of the material
  23783. */
  23784. set alpha(value: number);
  23785. /**
  23786. * Gets the alpha value of the material
  23787. */
  23788. get alpha(): number;
  23789. /**
  23790. * Specifies if back face culling is enabled
  23791. */
  23792. protected _backFaceCulling: boolean;
  23793. /**
  23794. * Sets the back-face culling state
  23795. */
  23796. set backFaceCulling(value: boolean);
  23797. /**
  23798. * Gets the back-face culling state
  23799. */
  23800. get backFaceCulling(): boolean;
  23801. /**
  23802. * Stores the value for side orientation
  23803. */
  23804. sideOrientation: number;
  23805. /**
  23806. * Callback triggered when the material is compiled
  23807. */
  23808. onCompiled: Nullable<(effect: Effect) => void>;
  23809. /**
  23810. * Callback triggered when an error occurs
  23811. */
  23812. onError: Nullable<(effect: Effect, errors: string) => void>;
  23813. /**
  23814. * Callback triggered to get the render target textures
  23815. */
  23816. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23817. /**
  23818. * Gets a boolean indicating that current material needs to register RTT
  23819. */
  23820. get hasRenderTargetTextures(): boolean;
  23821. /**
  23822. * Specifies if the material should be serialized
  23823. */
  23824. doNotSerialize: boolean;
  23825. /**
  23826. * @hidden
  23827. */
  23828. _storeEffectOnSubMeshes: boolean;
  23829. /**
  23830. * Stores the animations for the material
  23831. */
  23832. animations: Nullable<Array<Animation>>;
  23833. /**
  23834. * An event triggered when the material is disposed
  23835. */
  23836. onDisposeObservable: Observable<Material>;
  23837. /**
  23838. * An observer which watches for dispose events
  23839. */
  23840. private _onDisposeObserver;
  23841. private _onUnBindObservable;
  23842. /**
  23843. * Called during a dispose event
  23844. */
  23845. set onDispose(callback: () => void);
  23846. private _onBindObservable;
  23847. /**
  23848. * An event triggered when the material is bound
  23849. */
  23850. get onBindObservable(): Observable<AbstractMesh>;
  23851. /**
  23852. * An observer which watches for bind events
  23853. */
  23854. private _onBindObserver;
  23855. /**
  23856. * Called during a bind event
  23857. */
  23858. set onBind(callback: (Mesh: AbstractMesh) => void);
  23859. /**
  23860. * An event triggered when the material is unbound
  23861. */
  23862. get onUnBindObservable(): Observable<Material>;
  23863. protected _onEffectCreatedObservable: Nullable<Observable<{
  23864. effect: Effect;
  23865. subMesh: Nullable<SubMesh>;
  23866. }>>;
  23867. /**
  23868. * An event triggered when the effect is (re)created
  23869. */
  23870. get onEffectCreatedObservable(): Observable<{
  23871. effect: Effect;
  23872. subMesh: Nullable<SubMesh>;
  23873. }>;
  23874. /**
  23875. * Stores the value of the alpha mode
  23876. */
  23877. private _alphaMode;
  23878. /**
  23879. * Sets the value of the alpha mode.
  23880. *
  23881. * | Value | Type | Description |
  23882. * | --- | --- | --- |
  23883. * | 0 | ALPHA_DISABLE | |
  23884. * | 1 | ALPHA_ADD | |
  23885. * | 2 | ALPHA_COMBINE | |
  23886. * | 3 | ALPHA_SUBTRACT | |
  23887. * | 4 | ALPHA_MULTIPLY | |
  23888. * | 5 | ALPHA_MAXIMIZED | |
  23889. * | 6 | ALPHA_ONEONE | |
  23890. * | 7 | ALPHA_PREMULTIPLIED | |
  23891. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23892. * | 9 | ALPHA_INTERPOLATE | |
  23893. * | 10 | ALPHA_SCREENMODE | |
  23894. *
  23895. */
  23896. set alphaMode(value: number);
  23897. /**
  23898. * Gets the value of the alpha mode
  23899. */
  23900. get alphaMode(): number;
  23901. /**
  23902. * Stores the state of the need depth pre-pass value
  23903. */
  23904. private _needDepthPrePass;
  23905. /**
  23906. * Sets the need depth pre-pass value
  23907. */
  23908. set needDepthPrePass(value: boolean);
  23909. /**
  23910. * Gets the depth pre-pass value
  23911. */
  23912. get needDepthPrePass(): boolean;
  23913. /**
  23914. * Specifies if depth writing should be disabled
  23915. */
  23916. disableDepthWrite: boolean;
  23917. /**
  23918. * Specifies if color writing should be disabled
  23919. */
  23920. disableColorWrite: boolean;
  23921. /**
  23922. * Specifies if depth writing should be forced
  23923. */
  23924. forceDepthWrite: boolean;
  23925. /**
  23926. * Specifies the depth function that should be used. 0 means the default engine function
  23927. */
  23928. depthFunction: number;
  23929. /**
  23930. * Specifies if there should be a separate pass for culling
  23931. */
  23932. separateCullingPass: boolean;
  23933. /**
  23934. * Stores the state specifing if fog should be enabled
  23935. */
  23936. private _fogEnabled;
  23937. /**
  23938. * Sets the state for enabling fog
  23939. */
  23940. set fogEnabled(value: boolean);
  23941. /**
  23942. * Gets the value of the fog enabled state
  23943. */
  23944. get fogEnabled(): boolean;
  23945. /**
  23946. * Stores the size of points
  23947. */
  23948. pointSize: number;
  23949. /**
  23950. * Stores the z offset value
  23951. */
  23952. zOffset: number;
  23953. get wireframe(): boolean;
  23954. /**
  23955. * Sets the state of wireframe mode
  23956. */
  23957. set wireframe(value: boolean);
  23958. /**
  23959. * Gets the value specifying if point clouds are enabled
  23960. */
  23961. get pointsCloud(): boolean;
  23962. /**
  23963. * Sets the state of point cloud mode
  23964. */
  23965. set pointsCloud(value: boolean);
  23966. /**
  23967. * Gets the material fill mode
  23968. */
  23969. get fillMode(): number;
  23970. /**
  23971. * Sets the material fill mode
  23972. */
  23973. set fillMode(value: number);
  23974. /**
  23975. * @hidden
  23976. * Stores the effects for the material
  23977. */
  23978. _effect: Nullable<Effect>;
  23979. /**
  23980. * Specifies if uniform buffers should be used
  23981. */
  23982. private _useUBO;
  23983. /**
  23984. * Stores a reference to the scene
  23985. */
  23986. private _scene;
  23987. /**
  23988. * Stores the fill mode state
  23989. */
  23990. private _fillMode;
  23991. /**
  23992. * Specifies if the depth write state should be cached
  23993. */
  23994. private _cachedDepthWriteState;
  23995. /**
  23996. * Specifies if the color write state should be cached
  23997. */
  23998. private _cachedColorWriteState;
  23999. /**
  24000. * Specifies if the depth function state should be cached
  24001. */
  24002. private _cachedDepthFunctionState;
  24003. /**
  24004. * Stores the uniform buffer
  24005. */
  24006. protected _uniformBuffer: UniformBuffer;
  24007. /** @hidden */
  24008. _indexInSceneMaterialArray: number;
  24009. /** @hidden */
  24010. meshMap: Nullable<{
  24011. [id: string]: AbstractMesh | undefined;
  24012. }>;
  24013. /**
  24014. * Creates a material instance
  24015. * @param name defines the name of the material
  24016. * @param scene defines the scene to reference
  24017. * @param doNotAdd specifies if the material should be added to the scene
  24018. */
  24019. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24020. /**
  24021. * Returns a string representation of the current material
  24022. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24023. * @returns a string with material information
  24024. */
  24025. toString(fullDetails?: boolean): string;
  24026. /**
  24027. * Gets the class name of the material
  24028. * @returns a string with the class name of the material
  24029. */
  24030. getClassName(): string;
  24031. /**
  24032. * Specifies if updates for the material been locked
  24033. */
  24034. get isFrozen(): boolean;
  24035. /**
  24036. * Locks updates for the material
  24037. */
  24038. freeze(): void;
  24039. /**
  24040. * Unlocks updates for the material
  24041. */
  24042. unfreeze(): void;
  24043. /**
  24044. * Specifies if the material is ready to be used
  24045. * @param mesh defines the mesh to check
  24046. * @param useInstances specifies if instances should be used
  24047. * @returns a boolean indicating if the material is ready to be used
  24048. */
  24049. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24050. /**
  24051. * Specifies that the submesh is ready to be used
  24052. * @param mesh defines the mesh to check
  24053. * @param subMesh defines which submesh to check
  24054. * @param useInstances specifies that instances should be used
  24055. * @returns a boolean indicating that the submesh is ready or not
  24056. */
  24057. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  24058. /**
  24059. * Returns the material effect
  24060. * @returns the effect associated with the material
  24061. */
  24062. getEffect(): Nullable<Effect>;
  24063. /**
  24064. * Returns the current scene
  24065. * @returns a Scene
  24066. */
  24067. getScene(): Scene;
  24068. /**
  24069. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24070. */
  24071. protected _forceAlphaTest: boolean;
  24072. /**
  24073. * The transparency mode of the material.
  24074. */
  24075. protected _transparencyMode: Nullable<number>;
  24076. /**
  24077. * Gets the current transparency mode.
  24078. */
  24079. get transparencyMode(): Nullable<number>;
  24080. /**
  24081. * Sets the transparency mode of the material.
  24082. *
  24083. * | Value | Type | Description |
  24084. * | ----- | ----------------------------------- | ----------- |
  24085. * | 0 | OPAQUE | |
  24086. * | 1 | ALPHATEST | |
  24087. * | 2 | ALPHABLEND | |
  24088. * | 3 | ALPHATESTANDBLEND | |
  24089. *
  24090. */
  24091. set transparencyMode(value: Nullable<number>);
  24092. /**
  24093. * Returns true if alpha blending should be disabled.
  24094. */
  24095. protected get _disableAlphaBlending(): boolean;
  24096. /**
  24097. * Specifies whether or not this material should be rendered in alpha blend mode.
  24098. * @returns a boolean specifying if alpha blending is needed
  24099. */
  24100. needAlphaBlending(): boolean;
  24101. /**
  24102. * Specifies if the mesh will require alpha blending
  24103. * @param mesh defines the mesh to check
  24104. * @returns a boolean specifying if alpha blending is needed for the mesh
  24105. */
  24106. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24107. /**
  24108. * Specifies whether or not this material should be rendered in alpha test mode.
  24109. * @returns a boolean specifying if an alpha test is needed.
  24110. */
  24111. needAlphaTesting(): boolean;
  24112. /**
  24113. * Specifies if material alpha testing should be turned on for the mesh
  24114. * @param mesh defines the mesh to check
  24115. */
  24116. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24117. /**
  24118. * Gets the texture used for the alpha test
  24119. * @returns the texture to use for alpha testing
  24120. */
  24121. getAlphaTestTexture(): Nullable<BaseTexture>;
  24122. /**
  24123. * Marks the material to indicate that it needs to be re-calculated
  24124. */
  24125. markDirty(): void;
  24126. /** @hidden */
  24127. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24128. /**
  24129. * Binds the material to the mesh
  24130. * @param world defines the world transformation matrix
  24131. * @param mesh defines the mesh to bind the material to
  24132. */
  24133. bind(world: Matrix, mesh?: Mesh): void;
  24134. /**
  24135. * Binds the submesh to the material
  24136. * @param world defines the world transformation matrix
  24137. * @param mesh defines the mesh containing the submesh
  24138. * @param subMesh defines the submesh to bind the material to
  24139. */
  24140. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24141. /**
  24142. * Binds the world matrix to the material
  24143. * @param world defines the world transformation matrix
  24144. */
  24145. bindOnlyWorldMatrix(world: Matrix): void;
  24146. /**
  24147. * Binds the scene's uniform buffer to the effect.
  24148. * @param effect defines the effect to bind to the scene uniform buffer
  24149. * @param sceneUbo defines the uniform buffer storing scene data
  24150. */
  24151. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24152. /**
  24153. * Binds the view matrix to the effect
  24154. * @param effect defines the effect to bind the view matrix to
  24155. */
  24156. bindView(effect: Effect): void;
  24157. /**
  24158. * Binds the view projection matrix to the effect
  24159. * @param effect defines the effect to bind the view projection matrix to
  24160. */
  24161. bindViewProjection(effect: Effect): void;
  24162. /**
  24163. * Processes to execute after binding the material to a mesh
  24164. * @param mesh defines the rendered mesh
  24165. */
  24166. protected _afterBind(mesh?: Mesh): void;
  24167. /**
  24168. * Unbinds the material from the mesh
  24169. */
  24170. unbind(): void;
  24171. /**
  24172. * Gets the active textures from the material
  24173. * @returns an array of textures
  24174. */
  24175. getActiveTextures(): BaseTexture[];
  24176. /**
  24177. * Specifies if the material uses a texture
  24178. * @param texture defines the texture to check against the material
  24179. * @returns a boolean specifying if the material uses the texture
  24180. */
  24181. hasTexture(texture: BaseTexture): boolean;
  24182. /**
  24183. * Makes a duplicate of the material, and gives it a new name
  24184. * @param name defines the new name for the duplicated material
  24185. * @returns the cloned material
  24186. */
  24187. clone(name: string): Nullable<Material>;
  24188. /**
  24189. * Gets the meshes bound to the material
  24190. * @returns an array of meshes bound to the material
  24191. */
  24192. getBindedMeshes(): AbstractMesh[];
  24193. /**
  24194. * Force shader compilation
  24195. * @param mesh defines the mesh associated with this material
  24196. * @param onCompiled defines a function to execute once the material is compiled
  24197. * @param options defines the options to configure the compilation
  24198. * @param onError defines a function to execute if the material fails compiling
  24199. */
  24200. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24201. /**
  24202. * Force shader compilation
  24203. * @param mesh defines the mesh that will use this material
  24204. * @param options defines additional options for compiling the shaders
  24205. * @returns a promise that resolves when the compilation completes
  24206. */
  24207. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24208. private static readonly _AllDirtyCallBack;
  24209. private static readonly _ImageProcessingDirtyCallBack;
  24210. private static readonly _TextureDirtyCallBack;
  24211. private static readonly _FresnelDirtyCallBack;
  24212. private static readonly _MiscDirtyCallBack;
  24213. private static readonly _LightsDirtyCallBack;
  24214. private static readonly _AttributeDirtyCallBack;
  24215. private static _FresnelAndMiscDirtyCallBack;
  24216. private static _TextureAndMiscDirtyCallBack;
  24217. private static readonly _DirtyCallbackArray;
  24218. private static readonly _RunDirtyCallBacks;
  24219. /**
  24220. * Marks a define in the material to indicate that it needs to be re-computed
  24221. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24222. */
  24223. markAsDirty(flag: number): void;
  24224. /**
  24225. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24226. * @param func defines a function which checks material defines against the submeshes
  24227. */
  24228. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24229. /**
  24230. * Indicates that we need to re-calculated for all submeshes
  24231. */
  24232. protected _markAllSubMeshesAsAllDirty(): void;
  24233. /**
  24234. * Indicates that image processing needs to be re-calculated for all submeshes
  24235. */
  24236. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24237. /**
  24238. * Indicates that textures need to be re-calculated for all submeshes
  24239. */
  24240. protected _markAllSubMeshesAsTexturesDirty(): void;
  24241. /**
  24242. * Indicates that fresnel needs to be re-calculated for all submeshes
  24243. */
  24244. protected _markAllSubMeshesAsFresnelDirty(): void;
  24245. /**
  24246. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24247. */
  24248. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24249. /**
  24250. * Indicates that lights need to be re-calculated for all submeshes
  24251. */
  24252. protected _markAllSubMeshesAsLightsDirty(): void;
  24253. /**
  24254. * Indicates that attributes need to be re-calculated for all submeshes
  24255. */
  24256. protected _markAllSubMeshesAsAttributesDirty(): void;
  24257. /**
  24258. * Indicates that misc needs to be re-calculated for all submeshes
  24259. */
  24260. protected _markAllSubMeshesAsMiscDirty(): void;
  24261. /**
  24262. * Indicates that textures and misc need to be re-calculated for all submeshes
  24263. */
  24264. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24265. /**
  24266. * Disposes the material
  24267. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24268. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24269. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24270. */
  24271. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24272. /** @hidden */
  24273. private releaseVertexArrayObject;
  24274. /**
  24275. * Serializes this material
  24276. * @returns the serialized material object
  24277. */
  24278. serialize(): any;
  24279. /**
  24280. * Creates a material from parsed material data
  24281. * @param parsedMaterial defines parsed material data
  24282. * @param scene defines the hosting scene
  24283. * @param rootUrl defines the root URL to use to load textures
  24284. * @returns a new material
  24285. */
  24286. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24287. }
  24288. }
  24289. declare module BABYLON {
  24290. /**
  24291. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24292. * separate meshes. This can be use to improve performances.
  24293. * @see http://doc.babylonjs.com/how_to/multi_materials
  24294. */
  24295. export class MultiMaterial extends Material {
  24296. private _subMaterials;
  24297. /**
  24298. * Gets or Sets the list of Materials used within the multi material.
  24299. * They need to be ordered according to the submeshes order in the associated mesh
  24300. */
  24301. get subMaterials(): Nullable<Material>[];
  24302. set subMaterials(value: Nullable<Material>[]);
  24303. /**
  24304. * Function used to align with Node.getChildren()
  24305. * @returns the list of Materials used within the multi material
  24306. */
  24307. getChildren(): Nullable<Material>[];
  24308. /**
  24309. * Instantiates a new Multi Material
  24310. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24311. * separate meshes. This can be use to improve performances.
  24312. * @see http://doc.babylonjs.com/how_to/multi_materials
  24313. * @param name Define the name in the scene
  24314. * @param scene Define the scene the material belongs to
  24315. */
  24316. constructor(name: string, scene: Scene);
  24317. private _hookArray;
  24318. /**
  24319. * Get one of the submaterial by its index in the submaterials array
  24320. * @param index The index to look the sub material at
  24321. * @returns The Material if the index has been defined
  24322. */
  24323. getSubMaterial(index: number): Nullable<Material>;
  24324. /**
  24325. * Get the list of active textures for the whole sub materials list.
  24326. * @returns All the textures that will be used during the rendering
  24327. */
  24328. getActiveTextures(): BaseTexture[];
  24329. /**
  24330. * Gets the current class name of the material e.g. "MultiMaterial"
  24331. * Mainly use in serialization.
  24332. * @returns the class name
  24333. */
  24334. getClassName(): string;
  24335. /**
  24336. * Checks if the material is ready to render the requested sub mesh
  24337. * @param mesh Define the mesh the submesh belongs to
  24338. * @param subMesh Define the sub mesh to look readyness for
  24339. * @param useInstances Define whether or not the material is used with instances
  24340. * @returns true if ready, otherwise false
  24341. */
  24342. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  24343. /**
  24344. * Clones the current material and its related sub materials
  24345. * @param name Define the name of the newly cloned material
  24346. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24347. * @returns the cloned material
  24348. */
  24349. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24350. /**
  24351. * Serializes the materials into a JSON representation.
  24352. * @returns the JSON representation
  24353. */
  24354. serialize(): any;
  24355. /**
  24356. * Dispose the material and release its associated resources
  24357. * @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)
  24358. * @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)
  24359. * @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)
  24360. */
  24361. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24362. /**
  24363. * Creates a MultiMaterial from parsed MultiMaterial data.
  24364. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24365. * @param scene defines the hosting scene
  24366. * @returns a new MultiMaterial
  24367. */
  24368. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24369. }
  24370. }
  24371. declare module BABYLON {
  24372. /**
  24373. * Base class for submeshes
  24374. */
  24375. export class BaseSubMesh {
  24376. /** @hidden */
  24377. _materialDefines: Nullable<MaterialDefines>;
  24378. /** @hidden */
  24379. _materialEffect: Nullable<Effect>;
  24380. /** @hidden */
  24381. _effectOverride: Nullable<Effect>;
  24382. /**
  24383. * Gets material defines used by the effect associated to the sub mesh
  24384. */
  24385. get materialDefines(): Nullable<MaterialDefines>;
  24386. /**
  24387. * Sets material defines used by the effect associated to the sub mesh
  24388. */
  24389. set materialDefines(defines: Nullable<MaterialDefines>);
  24390. /**
  24391. * Gets associated effect
  24392. */
  24393. get effect(): Nullable<Effect>;
  24394. /**
  24395. * Sets associated effect (effect used to render this submesh)
  24396. * @param effect defines the effect to associate with
  24397. * @param defines defines the set of defines used to compile this effect
  24398. */
  24399. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24400. }
  24401. /**
  24402. * Defines a subdivision inside a mesh
  24403. */
  24404. export class SubMesh extends BaseSubMesh implements ICullable {
  24405. /** the material index to use */
  24406. materialIndex: number;
  24407. /** vertex index start */
  24408. verticesStart: number;
  24409. /** vertices count */
  24410. verticesCount: number;
  24411. /** index start */
  24412. indexStart: number;
  24413. /** indices count */
  24414. indexCount: number;
  24415. /** @hidden */
  24416. _linesIndexCount: number;
  24417. private _mesh;
  24418. private _renderingMesh;
  24419. private _boundingInfo;
  24420. private _linesIndexBuffer;
  24421. /** @hidden */
  24422. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24423. /** @hidden */
  24424. _trianglePlanes: Plane[];
  24425. /** @hidden */
  24426. _lastColliderTransformMatrix: Nullable<Matrix>;
  24427. /** @hidden */
  24428. _renderId: number;
  24429. /** @hidden */
  24430. _alphaIndex: number;
  24431. /** @hidden */
  24432. _distanceToCamera: number;
  24433. /** @hidden */
  24434. _id: number;
  24435. private _currentMaterial;
  24436. /**
  24437. * Add a new submesh to a mesh
  24438. * @param materialIndex defines the material index to use
  24439. * @param verticesStart defines vertex index start
  24440. * @param verticesCount defines vertices count
  24441. * @param indexStart defines index start
  24442. * @param indexCount defines indices count
  24443. * @param mesh defines the parent mesh
  24444. * @param renderingMesh defines an optional rendering mesh
  24445. * @param createBoundingBox defines if bounding box should be created for this submesh
  24446. * @returns the new submesh
  24447. */
  24448. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24449. /**
  24450. * Creates a new submesh
  24451. * @param materialIndex defines the material index to use
  24452. * @param verticesStart defines vertex index start
  24453. * @param verticesCount defines vertices count
  24454. * @param indexStart defines index start
  24455. * @param indexCount defines indices count
  24456. * @param mesh defines the parent mesh
  24457. * @param renderingMesh defines an optional rendering mesh
  24458. * @param createBoundingBox defines if bounding box should be created for this submesh
  24459. */
  24460. constructor(
  24461. /** the material index to use */
  24462. materialIndex: number,
  24463. /** vertex index start */
  24464. verticesStart: number,
  24465. /** vertices count */
  24466. verticesCount: number,
  24467. /** index start */
  24468. indexStart: number,
  24469. /** indices count */
  24470. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  24471. /**
  24472. * Returns true if this submesh covers the entire parent mesh
  24473. * @ignorenaming
  24474. */
  24475. get IsGlobal(): boolean;
  24476. /**
  24477. * Returns the submesh BoudingInfo object
  24478. * @returns current bounding info (or mesh's one if the submesh is global)
  24479. */
  24480. getBoundingInfo(): BoundingInfo;
  24481. /**
  24482. * Sets the submesh BoundingInfo
  24483. * @param boundingInfo defines the new bounding info to use
  24484. * @returns the SubMesh
  24485. */
  24486. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24487. /**
  24488. * Returns the mesh of the current submesh
  24489. * @return the parent mesh
  24490. */
  24491. getMesh(): AbstractMesh;
  24492. /**
  24493. * Returns the rendering mesh of the submesh
  24494. * @returns the rendering mesh (could be different from parent mesh)
  24495. */
  24496. getRenderingMesh(): Mesh;
  24497. /**
  24498. * Returns the submesh material
  24499. * @returns null or the current material
  24500. */
  24501. getMaterial(): Nullable<Material>;
  24502. /**
  24503. * Sets a new updated BoundingInfo object to the submesh
  24504. * @param data defines an optional position array to use to determine the bounding info
  24505. * @returns the SubMesh
  24506. */
  24507. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24508. /** @hidden */
  24509. _checkCollision(collider: Collider): boolean;
  24510. /**
  24511. * Updates the submesh BoundingInfo
  24512. * @param world defines the world matrix to use to update the bounding info
  24513. * @returns the submesh
  24514. */
  24515. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24516. /**
  24517. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24518. * @param frustumPlanes defines the frustum planes
  24519. * @returns true if the submesh is intersecting with the frustum
  24520. */
  24521. isInFrustum(frustumPlanes: Plane[]): boolean;
  24522. /**
  24523. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24524. * @param frustumPlanes defines the frustum planes
  24525. * @returns true if the submesh is inside the frustum
  24526. */
  24527. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24528. /**
  24529. * Renders the submesh
  24530. * @param enableAlphaMode defines if alpha needs to be used
  24531. * @returns the submesh
  24532. */
  24533. render(enableAlphaMode: boolean): SubMesh;
  24534. /**
  24535. * @hidden
  24536. */
  24537. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24538. /**
  24539. * Checks if the submesh intersects with a ray
  24540. * @param ray defines the ray to test
  24541. * @returns true is the passed ray intersects the submesh bounding box
  24542. */
  24543. canIntersects(ray: Ray): boolean;
  24544. /**
  24545. * Intersects current submesh with a ray
  24546. * @param ray defines the ray to test
  24547. * @param positions defines mesh's positions array
  24548. * @param indices defines mesh's indices array
  24549. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24550. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24551. * @returns intersection info or null if no intersection
  24552. */
  24553. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24554. /** @hidden */
  24555. private _intersectLines;
  24556. /** @hidden */
  24557. private _intersectUnIndexedLines;
  24558. /** @hidden */
  24559. private _intersectTriangles;
  24560. /** @hidden */
  24561. private _intersectUnIndexedTriangles;
  24562. /** @hidden */
  24563. _rebuild(): void;
  24564. /**
  24565. * Creates a new submesh from the passed mesh
  24566. * @param newMesh defines the new hosting mesh
  24567. * @param newRenderingMesh defines an optional rendering mesh
  24568. * @returns the new submesh
  24569. */
  24570. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24571. /**
  24572. * Release associated resources
  24573. */
  24574. dispose(): void;
  24575. /**
  24576. * Gets the class name
  24577. * @returns the string "SubMesh".
  24578. */
  24579. getClassName(): string;
  24580. /**
  24581. * Creates a new submesh from indices data
  24582. * @param materialIndex the index of the main mesh material
  24583. * @param startIndex the index where to start the copy in the mesh indices array
  24584. * @param indexCount the number of indices to copy then from the startIndex
  24585. * @param mesh the main mesh to create the submesh from
  24586. * @param renderingMesh the optional rendering mesh
  24587. * @returns a new submesh
  24588. */
  24589. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24590. }
  24591. }
  24592. declare module BABYLON {
  24593. /**
  24594. * Class used to represent data loading progression
  24595. */
  24596. export class SceneLoaderFlags {
  24597. private static _ForceFullSceneLoadingForIncremental;
  24598. private static _ShowLoadingScreen;
  24599. private static _CleanBoneMatrixWeights;
  24600. private static _loggingLevel;
  24601. /**
  24602. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24603. */
  24604. static get ForceFullSceneLoadingForIncremental(): boolean;
  24605. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24606. /**
  24607. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24608. */
  24609. static get ShowLoadingScreen(): boolean;
  24610. static set ShowLoadingScreen(value: boolean);
  24611. /**
  24612. * Defines the current logging level (while loading the scene)
  24613. * @ignorenaming
  24614. */
  24615. static get loggingLevel(): number;
  24616. static set loggingLevel(value: number);
  24617. /**
  24618. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24619. */
  24620. static get CleanBoneMatrixWeights(): boolean;
  24621. static set CleanBoneMatrixWeights(value: boolean);
  24622. }
  24623. }
  24624. declare module BABYLON {
  24625. /**
  24626. * Class used to store geometry data (vertex buffers + index buffer)
  24627. */
  24628. export class Geometry implements IGetSetVerticesData {
  24629. /**
  24630. * Gets or sets the ID of the geometry
  24631. */
  24632. id: string;
  24633. /**
  24634. * Gets or sets the unique ID of the geometry
  24635. */
  24636. uniqueId: number;
  24637. /**
  24638. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24639. */
  24640. delayLoadState: number;
  24641. /**
  24642. * Gets the file containing the data to load when running in delay load state
  24643. */
  24644. delayLoadingFile: Nullable<string>;
  24645. /**
  24646. * Callback called when the geometry is updated
  24647. */
  24648. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24649. private _scene;
  24650. private _engine;
  24651. private _meshes;
  24652. private _totalVertices;
  24653. /** @hidden */
  24654. _indices: IndicesArray;
  24655. /** @hidden */
  24656. _vertexBuffers: {
  24657. [key: string]: VertexBuffer;
  24658. };
  24659. private _isDisposed;
  24660. private _extend;
  24661. private _boundingBias;
  24662. /** @hidden */
  24663. _delayInfo: Array<string>;
  24664. private _indexBuffer;
  24665. private _indexBufferIsUpdatable;
  24666. /** @hidden */
  24667. _boundingInfo: Nullable<BoundingInfo>;
  24668. /** @hidden */
  24669. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24670. /** @hidden */
  24671. _softwareSkinningFrameId: number;
  24672. private _vertexArrayObjects;
  24673. private _updatable;
  24674. /** @hidden */
  24675. _positions: Nullable<Vector3[]>;
  24676. /**
  24677. * 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
  24678. */
  24679. get boundingBias(): Vector2;
  24680. /**
  24681. * 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
  24682. */
  24683. set boundingBias(value: Vector2);
  24684. /**
  24685. * Static function used to attach a new empty geometry to a mesh
  24686. * @param mesh defines the mesh to attach the geometry to
  24687. * @returns the new Geometry
  24688. */
  24689. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24690. /** Get the list of meshes using this geometry */
  24691. get meshes(): Mesh[];
  24692. /**
  24693. * Creates a new geometry
  24694. * @param id defines the unique ID
  24695. * @param scene defines the hosting scene
  24696. * @param vertexData defines the VertexData used to get geometry data
  24697. * @param updatable defines if geometry must be updatable (false by default)
  24698. * @param mesh defines the mesh that will be associated with the geometry
  24699. */
  24700. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24701. /**
  24702. * Gets the current extend of the geometry
  24703. */
  24704. get extend(): {
  24705. minimum: Vector3;
  24706. maximum: Vector3;
  24707. };
  24708. /**
  24709. * Gets the hosting scene
  24710. * @returns the hosting Scene
  24711. */
  24712. getScene(): Scene;
  24713. /**
  24714. * Gets the hosting engine
  24715. * @returns the hosting Engine
  24716. */
  24717. getEngine(): Engine;
  24718. /**
  24719. * Defines if the geometry is ready to use
  24720. * @returns true if the geometry is ready to be used
  24721. */
  24722. isReady(): boolean;
  24723. /**
  24724. * Gets a value indicating that the geometry should not be serialized
  24725. */
  24726. get doNotSerialize(): boolean;
  24727. /** @hidden */
  24728. _rebuild(): void;
  24729. /**
  24730. * Affects all geometry data in one call
  24731. * @param vertexData defines the geometry data
  24732. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24733. */
  24734. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24735. /**
  24736. * Set specific vertex data
  24737. * @param kind defines the data kind (Position, normal, etc...)
  24738. * @param data defines the vertex data to use
  24739. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24740. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24741. */
  24742. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24743. /**
  24744. * Removes a specific vertex data
  24745. * @param kind defines the data kind (Position, normal, etc...)
  24746. */
  24747. removeVerticesData(kind: string): void;
  24748. /**
  24749. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24750. * @param buffer defines the vertex buffer to use
  24751. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24752. */
  24753. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24754. /**
  24755. * Update a specific vertex buffer
  24756. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24757. * It will do nothing if the buffer is not updatable
  24758. * @param kind defines the data kind (Position, normal, etc...)
  24759. * @param data defines the data to use
  24760. * @param offset defines the offset in the target buffer where to store the data
  24761. * @param useBytes set to true if the offset is in bytes
  24762. */
  24763. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24764. /**
  24765. * Update a specific vertex buffer
  24766. * This function will create a new buffer if the current one is not updatable
  24767. * @param kind defines the data kind (Position, normal, etc...)
  24768. * @param data defines the data to use
  24769. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24770. */
  24771. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24772. private _updateBoundingInfo;
  24773. /** @hidden */
  24774. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24775. /**
  24776. * Gets total number of vertices
  24777. * @returns the total number of vertices
  24778. */
  24779. getTotalVertices(): number;
  24780. /**
  24781. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24782. * @param kind defines the data kind (Position, normal, etc...)
  24783. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24784. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24785. * @returns a float array containing vertex data
  24786. */
  24787. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24788. /**
  24789. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24790. * @param kind defines the data kind (Position, normal, etc...)
  24791. * @returns true if the vertex buffer with the specified kind is updatable
  24792. */
  24793. isVertexBufferUpdatable(kind: string): boolean;
  24794. /**
  24795. * Gets a specific vertex buffer
  24796. * @param kind defines the data kind (Position, normal, etc...)
  24797. * @returns a VertexBuffer
  24798. */
  24799. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24800. /**
  24801. * Returns all vertex buffers
  24802. * @return an object holding all vertex buffers indexed by kind
  24803. */
  24804. getVertexBuffers(): Nullable<{
  24805. [key: string]: VertexBuffer;
  24806. }>;
  24807. /**
  24808. * Gets a boolean indicating if specific vertex buffer is present
  24809. * @param kind defines the data kind (Position, normal, etc...)
  24810. * @returns true if data is present
  24811. */
  24812. isVerticesDataPresent(kind: string): boolean;
  24813. /**
  24814. * Gets a list of all attached data kinds (Position, normal, etc...)
  24815. * @returns a list of string containing all kinds
  24816. */
  24817. getVerticesDataKinds(): string[];
  24818. /**
  24819. * Update index buffer
  24820. * @param indices defines the indices to store in the index buffer
  24821. * @param offset defines the offset in the target buffer where to store the data
  24822. * @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)
  24823. */
  24824. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24825. /**
  24826. * Creates a new index buffer
  24827. * @param indices defines the indices to store in the index buffer
  24828. * @param totalVertices defines the total number of vertices (could be null)
  24829. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24830. */
  24831. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24832. /**
  24833. * Return the total number of indices
  24834. * @returns the total number of indices
  24835. */
  24836. getTotalIndices(): number;
  24837. /**
  24838. * Gets the index buffer array
  24839. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24840. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24841. * @returns the index buffer array
  24842. */
  24843. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24844. /**
  24845. * Gets the index buffer
  24846. * @return the index buffer
  24847. */
  24848. getIndexBuffer(): Nullable<DataBuffer>;
  24849. /** @hidden */
  24850. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24851. /**
  24852. * Release the associated resources for a specific mesh
  24853. * @param mesh defines the source mesh
  24854. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24855. */
  24856. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24857. /**
  24858. * Apply current geometry to a given mesh
  24859. * @param mesh defines the mesh to apply geometry to
  24860. */
  24861. applyToMesh(mesh: Mesh): void;
  24862. private _updateExtend;
  24863. private _applyToMesh;
  24864. private notifyUpdate;
  24865. /**
  24866. * Load the geometry if it was flagged as delay loaded
  24867. * @param scene defines the hosting scene
  24868. * @param onLoaded defines a callback called when the geometry is loaded
  24869. */
  24870. load(scene: Scene, onLoaded?: () => void): void;
  24871. private _queueLoad;
  24872. /**
  24873. * Invert the geometry to move from a right handed system to a left handed one.
  24874. */
  24875. toLeftHanded(): void;
  24876. /** @hidden */
  24877. _resetPointsArrayCache(): void;
  24878. /** @hidden */
  24879. _generatePointsArray(): boolean;
  24880. /**
  24881. * Gets a value indicating if the geometry is disposed
  24882. * @returns true if the geometry was disposed
  24883. */
  24884. isDisposed(): boolean;
  24885. private _disposeVertexArrayObjects;
  24886. /**
  24887. * Free all associated resources
  24888. */
  24889. dispose(): void;
  24890. /**
  24891. * Clone the current geometry into a new geometry
  24892. * @param id defines the unique ID of the new geometry
  24893. * @returns a new geometry object
  24894. */
  24895. copy(id: string): Geometry;
  24896. /**
  24897. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24898. * @return a JSON representation of the current geometry data (without the vertices data)
  24899. */
  24900. serialize(): any;
  24901. private toNumberArray;
  24902. /**
  24903. * Serialize all vertices data into a JSON oject
  24904. * @returns a JSON representation of the current geometry data
  24905. */
  24906. serializeVerticeData(): any;
  24907. /**
  24908. * Extracts a clone of a mesh geometry
  24909. * @param mesh defines the source mesh
  24910. * @param id defines the unique ID of the new geometry object
  24911. * @returns the new geometry object
  24912. */
  24913. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24914. /**
  24915. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24916. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24917. * Be aware Math.random() could cause collisions, but:
  24918. * "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"
  24919. * @returns a string containing a new GUID
  24920. */
  24921. static RandomId(): string;
  24922. /** @hidden */
  24923. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24924. private static _CleanMatricesWeights;
  24925. /**
  24926. * Create a new geometry from persisted data (Using .babylon file format)
  24927. * @param parsedVertexData defines the persisted data
  24928. * @param scene defines the hosting scene
  24929. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24930. * @returns the new geometry object
  24931. */
  24932. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24933. }
  24934. }
  24935. declare module BABYLON {
  24936. /**
  24937. * Define an interface for all classes that will get and set the data on vertices
  24938. */
  24939. export interface IGetSetVerticesData {
  24940. /**
  24941. * Gets a boolean indicating if specific vertex data is present
  24942. * @param kind defines the vertex data kind to use
  24943. * @returns true is data kind is present
  24944. */
  24945. isVerticesDataPresent(kind: string): boolean;
  24946. /**
  24947. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24948. * @param kind defines the data kind (Position, normal, etc...)
  24949. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24950. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24951. * @returns a float array containing vertex data
  24952. */
  24953. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24954. /**
  24955. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24956. * @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.
  24957. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24958. * @returns the indices array or an empty array if the mesh has no geometry
  24959. */
  24960. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24961. /**
  24962. * Set specific vertex data
  24963. * @param kind defines the data kind (Position, normal, etc...)
  24964. * @param data defines the vertex data to use
  24965. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24966. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24967. */
  24968. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24969. /**
  24970. * Update a specific associated vertex buffer
  24971. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24972. * - VertexBuffer.PositionKind
  24973. * - VertexBuffer.UVKind
  24974. * - VertexBuffer.UV2Kind
  24975. * - VertexBuffer.UV3Kind
  24976. * - VertexBuffer.UV4Kind
  24977. * - VertexBuffer.UV5Kind
  24978. * - VertexBuffer.UV6Kind
  24979. * - VertexBuffer.ColorKind
  24980. * - VertexBuffer.MatricesIndicesKind
  24981. * - VertexBuffer.MatricesIndicesExtraKind
  24982. * - VertexBuffer.MatricesWeightsKind
  24983. * - VertexBuffer.MatricesWeightsExtraKind
  24984. * @param data defines the data source
  24985. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24986. * @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)
  24987. */
  24988. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  24989. /**
  24990. * Creates a new index buffer
  24991. * @param indices defines the indices to store in the index buffer
  24992. * @param totalVertices defines the total number of vertices (could be null)
  24993. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24994. */
  24995. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  24996. }
  24997. /**
  24998. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  24999. */
  25000. export class VertexData {
  25001. /**
  25002. * Mesh side orientation : usually the external or front surface
  25003. */
  25004. static readonly FRONTSIDE: number;
  25005. /**
  25006. * Mesh side orientation : usually the internal or back surface
  25007. */
  25008. static readonly BACKSIDE: number;
  25009. /**
  25010. * Mesh side orientation : both internal and external or front and back surfaces
  25011. */
  25012. static readonly DOUBLESIDE: number;
  25013. /**
  25014. * Mesh side orientation : by default, `FRONTSIDE`
  25015. */
  25016. static readonly DEFAULTSIDE: number;
  25017. /**
  25018. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25019. */
  25020. positions: Nullable<FloatArray>;
  25021. /**
  25022. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25023. */
  25024. normals: Nullable<FloatArray>;
  25025. /**
  25026. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25027. */
  25028. tangents: Nullable<FloatArray>;
  25029. /**
  25030. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25031. */
  25032. uvs: Nullable<FloatArray>;
  25033. /**
  25034. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25035. */
  25036. uvs2: Nullable<FloatArray>;
  25037. /**
  25038. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25039. */
  25040. uvs3: Nullable<FloatArray>;
  25041. /**
  25042. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25043. */
  25044. uvs4: Nullable<FloatArray>;
  25045. /**
  25046. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25047. */
  25048. uvs5: Nullable<FloatArray>;
  25049. /**
  25050. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25051. */
  25052. uvs6: Nullable<FloatArray>;
  25053. /**
  25054. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25055. */
  25056. colors: Nullable<FloatArray>;
  25057. /**
  25058. * 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).
  25059. */
  25060. matricesIndices: Nullable<FloatArray>;
  25061. /**
  25062. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25063. */
  25064. matricesWeights: Nullable<FloatArray>;
  25065. /**
  25066. * An array extending the number of possible indices
  25067. */
  25068. matricesIndicesExtra: Nullable<FloatArray>;
  25069. /**
  25070. * An array extending the number of possible weights when the number of indices is extended
  25071. */
  25072. matricesWeightsExtra: Nullable<FloatArray>;
  25073. /**
  25074. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25075. */
  25076. indices: Nullable<IndicesArray>;
  25077. /**
  25078. * Uses the passed data array to set the set the values for the specified kind of data
  25079. * @param data a linear array of floating numbers
  25080. * @param kind the type of data that is being set, eg positions, colors etc
  25081. */
  25082. set(data: FloatArray, kind: string): void;
  25083. /**
  25084. * Associates the vertexData to the passed Mesh.
  25085. * Sets it as updatable or not (default `false`)
  25086. * @param mesh the mesh the vertexData is applied to
  25087. * @param updatable when used and having the value true allows new data to update the vertexData
  25088. * @returns the VertexData
  25089. */
  25090. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25091. /**
  25092. * Associates the vertexData to the passed Geometry.
  25093. * Sets it as updatable or not (default `false`)
  25094. * @param geometry the geometry the vertexData is applied to
  25095. * @param updatable when used and having the value true allows new data to update the vertexData
  25096. * @returns VertexData
  25097. */
  25098. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25099. /**
  25100. * Updates the associated mesh
  25101. * @param mesh the mesh to be updated
  25102. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25103. * @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
  25104. * @returns VertexData
  25105. */
  25106. updateMesh(mesh: Mesh): VertexData;
  25107. /**
  25108. * Updates the associated geometry
  25109. * @param geometry the geometry to be updated
  25110. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25111. * @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
  25112. * @returns VertexData.
  25113. */
  25114. updateGeometry(geometry: Geometry): VertexData;
  25115. private _applyTo;
  25116. private _update;
  25117. /**
  25118. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25119. * @param matrix the transforming matrix
  25120. * @returns the VertexData
  25121. */
  25122. transform(matrix: Matrix): VertexData;
  25123. /**
  25124. * Merges the passed VertexData into the current one
  25125. * @param other the VertexData to be merged into the current one
  25126. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25127. * @returns the modified VertexData
  25128. */
  25129. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25130. private _mergeElement;
  25131. private _validate;
  25132. /**
  25133. * Serializes the VertexData
  25134. * @returns a serialized object
  25135. */
  25136. serialize(): any;
  25137. /**
  25138. * Extracts the vertexData from a mesh
  25139. * @param mesh the mesh from which to extract the VertexData
  25140. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25141. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25142. * @returns the object VertexData associated to the passed mesh
  25143. */
  25144. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25145. /**
  25146. * Extracts the vertexData from the geometry
  25147. * @param geometry the geometry from which to extract the VertexData
  25148. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25149. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25150. * @returns the object VertexData associated to the passed mesh
  25151. */
  25152. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25153. private static _ExtractFrom;
  25154. /**
  25155. * Creates the VertexData for a Ribbon
  25156. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25157. * * pathArray array of paths, each of which an array of successive Vector3
  25158. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25159. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25160. * * 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
  25161. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25162. * * 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)
  25163. * * 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)
  25164. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25165. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25166. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25167. * @returns the VertexData of the ribbon
  25168. */
  25169. static CreateRibbon(options: {
  25170. pathArray: Vector3[][];
  25171. closeArray?: boolean;
  25172. closePath?: boolean;
  25173. offset?: number;
  25174. sideOrientation?: number;
  25175. frontUVs?: Vector4;
  25176. backUVs?: Vector4;
  25177. invertUV?: boolean;
  25178. uvs?: Vector2[];
  25179. colors?: Color4[];
  25180. }): VertexData;
  25181. /**
  25182. * Creates the VertexData for a box
  25183. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25184. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25185. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25186. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25187. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25188. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25189. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25190. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25191. * * 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)
  25192. * * 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)
  25193. * @returns the VertexData of the box
  25194. */
  25195. static CreateBox(options: {
  25196. size?: number;
  25197. width?: number;
  25198. height?: number;
  25199. depth?: number;
  25200. faceUV?: Vector4[];
  25201. faceColors?: Color4[];
  25202. sideOrientation?: number;
  25203. frontUVs?: Vector4;
  25204. backUVs?: Vector4;
  25205. }): VertexData;
  25206. /**
  25207. * Creates the VertexData for a tiled box
  25208. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25209. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25210. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25211. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25212. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25213. * @returns the VertexData of the box
  25214. */
  25215. static CreateTiledBox(options: {
  25216. pattern?: number;
  25217. width?: number;
  25218. height?: number;
  25219. depth?: number;
  25220. tileSize?: number;
  25221. tileWidth?: number;
  25222. tileHeight?: number;
  25223. alignHorizontal?: number;
  25224. alignVertical?: number;
  25225. faceUV?: Vector4[];
  25226. faceColors?: Color4[];
  25227. sideOrientation?: number;
  25228. }): VertexData;
  25229. /**
  25230. * Creates the VertexData for a tiled plane
  25231. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25232. * * pattern a limited pattern arrangement depending on the number
  25233. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25234. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25235. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25237. * * 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)
  25238. * * 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)
  25239. * @returns the VertexData of the tiled plane
  25240. */
  25241. static CreateTiledPlane(options: {
  25242. pattern?: number;
  25243. tileSize?: number;
  25244. tileWidth?: number;
  25245. tileHeight?: number;
  25246. size?: number;
  25247. width?: number;
  25248. height?: number;
  25249. alignHorizontal?: number;
  25250. alignVertical?: number;
  25251. sideOrientation?: number;
  25252. frontUVs?: Vector4;
  25253. backUVs?: Vector4;
  25254. }): VertexData;
  25255. /**
  25256. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25257. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25258. * * segments sets the number of horizontal strips optional, default 32
  25259. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25260. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25261. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25262. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25263. * * 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
  25264. * * 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
  25265. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25266. * * 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)
  25267. * * 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)
  25268. * @returns the VertexData of the ellipsoid
  25269. */
  25270. static CreateSphere(options: {
  25271. segments?: number;
  25272. diameter?: number;
  25273. diameterX?: number;
  25274. diameterY?: number;
  25275. diameterZ?: number;
  25276. arc?: number;
  25277. slice?: number;
  25278. sideOrientation?: number;
  25279. frontUVs?: Vector4;
  25280. backUVs?: Vector4;
  25281. }): VertexData;
  25282. /**
  25283. * Creates the VertexData for a cylinder, cone or prism
  25284. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25285. * * height sets the height (y direction) of the cylinder, optional, default 2
  25286. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25287. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25288. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25289. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25290. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25291. * * 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
  25292. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25293. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25294. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25295. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25297. * * 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)
  25298. * * 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)
  25299. * @returns the VertexData of the cylinder, cone or prism
  25300. */
  25301. static CreateCylinder(options: {
  25302. height?: number;
  25303. diameterTop?: number;
  25304. diameterBottom?: number;
  25305. diameter?: number;
  25306. tessellation?: number;
  25307. subdivisions?: number;
  25308. arc?: number;
  25309. faceColors?: Color4[];
  25310. faceUV?: Vector4[];
  25311. hasRings?: boolean;
  25312. enclose?: boolean;
  25313. sideOrientation?: number;
  25314. frontUVs?: Vector4;
  25315. backUVs?: Vector4;
  25316. }): VertexData;
  25317. /**
  25318. * Creates the VertexData for a torus
  25319. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25320. * * diameter the diameter of the torus, optional default 1
  25321. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25322. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25323. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25324. * * 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)
  25325. * * 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)
  25326. * @returns the VertexData of the torus
  25327. */
  25328. static CreateTorus(options: {
  25329. diameter?: number;
  25330. thickness?: number;
  25331. tessellation?: number;
  25332. sideOrientation?: number;
  25333. frontUVs?: Vector4;
  25334. backUVs?: Vector4;
  25335. }): VertexData;
  25336. /**
  25337. * Creates the VertexData of the LineSystem
  25338. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25339. * - lines an array of lines, each line being an array of successive Vector3
  25340. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25341. * @returns the VertexData of the LineSystem
  25342. */
  25343. static CreateLineSystem(options: {
  25344. lines: Vector3[][];
  25345. colors?: Nullable<Color4[][]>;
  25346. }): VertexData;
  25347. /**
  25348. * Create the VertexData for a DashedLines
  25349. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25350. * - points an array successive Vector3
  25351. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25352. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25353. * - dashNb the intended total number of dashes, optional, default 200
  25354. * @returns the VertexData for the DashedLines
  25355. */
  25356. static CreateDashedLines(options: {
  25357. points: Vector3[];
  25358. dashSize?: number;
  25359. gapSize?: number;
  25360. dashNb?: number;
  25361. }): VertexData;
  25362. /**
  25363. * Creates the VertexData for a Ground
  25364. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25365. * - width the width (x direction) of the ground, optional, default 1
  25366. * - height the height (z direction) of the ground, optional, default 1
  25367. * - subdivisions the number of subdivisions per side, optional, default 1
  25368. * @returns the VertexData of the Ground
  25369. */
  25370. static CreateGround(options: {
  25371. width?: number;
  25372. height?: number;
  25373. subdivisions?: number;
  25374. subdivisionsX?: number;
  25375. subdivisionsY?: number;
  25376. }): VertexData;
  25377. /**
  25378. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25379. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25380. * * xmin the ground minimum X coordinate, optional, default -1
  25381. * * zmin the ground minimum Z coordinate, optional, default -1
  25382. * * xmax the ground maximum X coordinate, optional, default 1
  25383. * * zmax the ground maximum Z coordinate, optional, default 1
  25384. * * 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}
  25385. * * 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}
  25386. * @returns the VertexData of the TiledGround
  25387. */
  25388. static CreateTiledGround(options: {
  25389. xmin: number;
  25390. zmin: number;
  25391. xmax: number;
  25392. zmax: number;
  25393. subdivisions?: {
  25394. w: number;
  25395. h: number;
  25396. };
  25397. precision?: {
  25398. w: number;
  25399. h: number;
  25400. };
  25401. }): VertexData;
  25402. /**
  25403. * Creates the VertexData of the Ground designed from a heightmap
  25404. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25405. * * width the width (x direction) of the ground
  25406. * * height the height (z direction) of the ground
  25407. * * subdivisions the number of subdivisions per side
  25408. * * minHeight the minimum altitude on the ground, optional, default 0
  25409. * * maxHeight the maximum altitude on the ground, optional default 1
  25410. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25411. * * buffer the array holding the image color data
  25412. * * bufferWidth the width of image
  25413. * * bufferHeight the height of image
  25414. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25415. * @returns the VertexData of the Ground designed from a heightmap
  25416. */
  25417. static CreateGroundFromHeightMap(options: {
  25418. width: number;
  25419. height: number;
  25420. subdivisions: number;
  25421. minHeight: number;
  25422. maxHeight: number;
  25423. colorFilter: Color3;
  25424. buffer: Uint8Array;
  25425. bufferWidth: number;
  25426. bufferHeight: number;
  25427. alphaFilter: number;
  25428. }): VertexData;
  25429. /**
  25430. * Creates the VertexData for a Plane
  25431. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25432. * * size sets the width and height of the plane to the value of size, optional default 1
  25433. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25434. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25435. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25436. * * 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)
  25437. * * 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)
  25438. * @returns the VertexData of the box
  25439. */
  25440. static CreatePlane(options: {
  25441. size?: number;
  25442. width?: number;
  25443. height?: number;
  25444. sideOrientation?: number;
  25445. frontUVs?: Vector4;
  25446. backUVs?: Vector4;
  25447. }): VertexData;
  25448. /**
  25449. * Creates the VertexData of the Disc or regular Polygon
  25450. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25451. * * radius the radius of the disc, optional default 0.5
  25452. * * tessellation the number of polygon sides, optional, default 64
  25453. * * 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
  25454. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25455. * * 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)
  25456. * * 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)
  25457. * @returns the VertexData of the box
  25458. */
  25459. static CreateDisc(options: {
  25460. radius?: number;
  25461. tessellation?: number;
  25462. arc?: number;
  25463. sideOrientation?: number;
  25464. frontUVs?: Vector4;
  25465. backUVs?: Vector4;
  25466. }): VertexData;
  25467. /**
  25468. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25469. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25470. * @param polygon a mesh built from polygonTriangulation.build()
  25471. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25472. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25473. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25474. * @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)
  25475. * @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)
  25476. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25477. * @returns the VertexData of the Polygon
  25478. */
  25479. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25480. /**
  25481. * Creates the VertexData of the IcoSphere
  25482. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25483. * * radius the radius of the IcoSphere, optional default 1
  25484. * * radiusX allows stretching in the x direction, optional, default radius
  25485. * * radiusY allows stretching in the y direction, optional, default radius
  25486. * * radiusZ allows stretching in the z direction, optional, default radius
  25487. * * flat when true creates a flat shaded mesh, optional, default true
  25488. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25489. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25490. * * 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)
  25491. * * 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)
  25492. * @returns the VertexData of the IcoSphere
  25493. */
  25494. static CreateIcoSphere(options: {
  25495. radius?: number;
  25496. radiusX?: number;
  25497. radiusY?: number;
  25498. radiusZ?: number;
  25499. flat?: boolean;
  25500. subdivisions?: number;
  25501. sideOrientation?: number;
  25502. frontUVs?: Vector4;
  25503. backUVs?: Vector4;
  25504. }): VertexData;
  25505. /**
  25506. * Creates the VertexData for a Polyhedron
  25507. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25508. * * type provided types are:
  25509. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25510. * * 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)
  25511. * * size the size of the IcoSphere, optional default 1
  25512. * * sizeX allows stretching in the x direction, optional, default size
  25513. * * sizeY allows stretching in the y direction, optional, default size
  25514. * * sizeZ allows stretching in the z direction, optional, default size
  25515. * * 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
  25516. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25517. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25518. * * flat when true creates a flat shaded mesh, optional, default true
  25519. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25521. * * 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)
  25522. * * 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)
  25523. * @returns the VertexData of the Polyhedron
  25524. */
  25525. static CreatePolyhedron(options: {
  25526. type?: number;
  25527. size?: number;
  25528. sizeX?: number;
  25529. sizeY?: number;
  25530. sizeZ?: number;
  25531. custom?: any;
  25532. faceUV?: Vector4[];
  25533. faceColors?: Color4[];
  25534. flat?: boolean;
  25535. sideOrientation?: number;
  25536. frontUVs?: Vector4;
  25537. backUVs?: Vector4;
  25538. }): VertexData;
  25539. /**
  25540. * Creates the VertexData for a TorusKnot
  25541. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25542. * * radius the radius of the torus knot, optional, default 2
  25543. * * tube the thickness of the tube, optional, default 0.5
  25544. * * radialSegments the number of sides on each tube segments, optional, default 32
  25545. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25546. * * p the number of windings around the z axis, optional, default 2
  25547. * * q the number of windings around the x axis, optional, default 3
  25548. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25549. * * 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)
  25550. * * 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)
  25551. * @returns the VertexData of the Torus Knot
  25552. */
  25553. static CreateTorusKnot(options: {
  25554. radius?: number;
  25555. tube?: number;
  25556. radialSegments?: number;
  25557. tubularSegments?: number;
  25558. p?: number;
  25559. q?: number;
  25560. sideOrientation?: number;
  25561. frontUVs?: Vector4;
  25562. backUVs?: Vector4;
  25563. }): VertexData;
  25564. /**
  25565. * Compute normals for given positions and indices
  25566. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25567. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25568. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25569. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25570. * * facetNormals : optional array of facet normals (vector3)
  25571. * * facetPositions : optional array of facet positions (vector3)
  25572. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25573. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25574. * * bInfo : optional bounding info, required for facetPartitioning computation
  25575. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25576. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25577. * * useRightHandedSystem: optional boolean to for right handed system computation
  25578. * * depthSort : optional boolean to enable the facet depth sort computation
  25579. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25580. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25581. */
  25582. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25583. facetNormals?: any;
  25584. facetPositions?: any;
  25585. facetPartitioning?: any;
  25586. ratio?: number;
  25587. bInfo?: any;
  25588. bbSize?: Vector3;
  25589. subDiv?: any;
  25590. useRightHandedSystem?: boolean;
  25591. depthSort?: boolean;
  25592. distanceTo?: Vector3;
  25593. depthSortedFacets?: any;
  25594. }): void;
  25595. /** @hidden */
  25596. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25597. /**
  25598. * Applies VertexData created from the imported parameters to the geometry
  25599. * @param parsedVertexData the parsed data from an imported file
  25600. * @param geometry the geometry to apply the VertexData to
  25601. */
  25602. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25603. }
  25604. }
  25605. declare module BABYLON {
  25606. /**
  25607. * Defines a target to use with MorphTargetManager
  25608. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25609. */
  25610. export class MorphTarget implements IAnimatable {
  25611. /** defines the name of the target */
  25612. name: string;
  25613. /**
  25614. * Gets or sets the list of animations
  25615. */
  25616. animations: Animation[];
  25617. private _scene;
  25618. private _positions;
  25619. private _normals;
  25620. private _tangents;
  25621. private _uvs;
  25622. private _influence;
  25623. private _uniqueId;
  25624. /**
  25625. * Observable raised when the influence changes
  25626. */
  25627. onInfluenceChanged: Observable<boolean>;
  25628. /** @hidden */
  25629. _onDataLayoutChanged: Observable<void>;
  25630. /**
  25631. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25632. */
  25633. get influence(): number;
  25634. set influence(influence: number);
  25635. /**
  25636. * Gets or sets the id of the morph Target
  25637. */
  25638. id: string;
  25639. private _animationPropertiesOverride;
  25640. /**
  25641. * Gets or sets the animation properties override
  25642. */
  25643. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25644. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25645. /**
  25646. * Creates a new MorphTarget
  25647. * @param name defines the name of the target
  25648. * @param influence defines the influence to use
  25649. * @param scene defines the scene the morphtarget belongs to
  25650. */
  25651. constructor(
  25652. /** defines the name of the target */
  25653. name: string, influence?: number, scene?: Nullable<Scene>);
  25654. /**
  25655. * Gets the unique ID of this manager
  25656. */
  25657. get uniqueId(): number;
  25658. /**
  25659. * Gets a boolean defining if the target contains position data
  25660. */
  25661. get hasPositions(): boolean;
  25662. /**
  25663. * Gets a boolean defining if the target contains normal data
  25664. */
  25665. get hasNormals(): boolean;
  25666. /**
  25667. * Gets a boolean defining if the target contains tangent data
  25668. */
  25669. get hasTangents(): boolean;
  25670. /**
  25671. * Gets a boolean defining if the target contains texture coordinates data
  25672. */
  25673. get hasUVs(): boolean;
  25674. /**
  25675. * Affects position data to this target
  25676. * @param data defines the position data to use
  25677. */
  25678. setPositions(data: Nullable<FloatArray>): void;
  25679. /**
  25680. * Gets the position data stored in this target
  25681. * @returns a FloatArray containing the position data (or null if not present)
  25682. */
  25683. getPositions(): Nullable<FloatArray>;
  25684. /**
  25685. * Affects normal data to this target
  25686. * @param data defines the normal data to use
  25687. */
  25688. setNormals(data: Nullable<FloatArray>): void;
  25689. /**
  25690. * Gets the normal data stored in this target
  25691. * @returns a FloatArray containing the normal data (or null if not present)
  25692. */
  25693. getNormals(): Nullable<FloatArray>;
  25694. /**
  25695. * Affects tangent data to this target
  25696. * @param data defines the tangent data to use
  25697. */
  25698. setTangents(data: Nullable<FloatArray>): void;
  25699. /**
  25700. * Gets the tangent data stored in this target
  25701. * @returns a FloatArray containing the tangent data (or null if not present)
  25702. */
  25703. getTangents(): Nullable<FloatArray>;
  25704. /**
  25705. * Affects texture coordinates data to this target
  25706. * @param data defines the texture coordinates data to use
  25707. */
  25708. setUVs(data: Nullable<FloatArray>): void;
  25709. /**
  25710. * Gets the texture coordinates data stored in this target
  25711. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25712. */
  25713. getUVs(): Nullable<FloatArray>;
  25714. /**
  25715. * Clone the current target
  25716. * @returns a new MorphTarget
  25717. */
  25718. clone(): MorphTarget;
  25719. /**
  25720. * Serializes the current target into a Serialization object
  25721. * @returns the serialized object
  25722. */
  25723. serialize(): any;
  25724. /**
  25725. * Returns the string "MorphTarget"
  25726. * @returns "MorphTarget"
  25727. */
  25728. getClassName(): string;
  25729. /**
  25730. * Creates a new target from serialized data
  25731. * @param serializationObject defines the serialized data to use
  25732. * @returns a new MorphTarget
  25733. */
  25734. static Parse(serializationObject: any): MorphTarget;
  25735. /**
  25736. * Creates a MorphTarget from mesh data
  25737. * @param mesh defines the source mesh
  25738. * @param name defines the name to use for the new target
  25739. * @param influence defines the influence to attach to the target
  25740. * @returns a new MorphTarget
  25741. */
  25742. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25743. }
  25744. }
  25745. declare module BABYLON {
  25746. /**
  25747. * This class is used to deform meshes using morphing between different targets
  25748. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25749. */
  25750. export class MorphTargetManager {
  25751. private _targets;
  25752. private _targetInfluenceChangedObservers;
  25753. private _targetDataLayoutChangedObservers;
  25754. private _activeTargets;
  25755. private _scene;
  25756. private _influences;
  25757. private _supportsNormals;
  25758. private _supportsTangents;
  25759. private _supportsUVs;
  25760. private _vertexCount;
  25761. private _uniqueId;
  25762. private _tempInfluences;
  25763. /**
  25764. * Gets or sets a boolean indicating if normals must be morphed
  25765. */
  25766. enableNormalMorphing: boolean;
  25767. /**
  25768. * Gets or sets a boolean indicating if tangents must be morphed
  25769. */
  25770. enableTangentMorphing: boolean;
  25771. /**
  25772. * Gets or sets a boolean indicating if UV must be morphed
  25773. */
  25774. enableUVMorphing: boolean;
  25775. /**
  25776. * Creates a new MorphTargetManager
  25777. * @param scene defines the current scene
  25778. */
  25779. constructor(scene?: Nullable<Scene>);
  25780. /**
  25781. * Gets the unique ID of this manager
  25782. */
  25783. get uniqueId(): number;
  25784. /**
  25785. * Gets the number of vertices handled by this manager
  25786. */
  25787. get vertexCount(): number;
  25788. /**
  25789. * Gets a boolean indicating if this manager supports morphing of normals
  25790. */
  25791. get supportsNormals(): boolean;
  25792. /**
  25793. * Gets a boolean indicating if this manager supports morphing of tangents
  25794. */
  25795. get supportsTangents(): boolean;
  25796. /**
  25797. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25798. */
  25799. get supportsUVs(): boolean;
  25800. /**
  25801. * Gets the number of targets stored in this manager
  25802. */
  25803. get numTargets(): number;
  25804. /**
  25805. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25806. */
  25807. get numInfluencers(): number;
  25808. /**
  25809. * Gets the list of influences (one per target)
  25810. */
  25811. get influences(): Float32Array;
  25812. /**
  25813. * Gets the active target at specified index. An active target is a target with an influence > 0
  25814. * @param index defines the index to check
  25815. * @returns the requested target
  25816. */
  25817. getActiveTarget(index: number): MorphTarget;
  25818. /**
  25819. * Gets the target at specified index
  25820. * @param index defines the index to check
  25821. * @returns the requested target
  25822. */
  25823. getTarget(index: number): MorphTarget;
  25824. /**
  25825. * Add a new target to this manager
  25826. * @param target defines the target to add
  25827. */
  25828. addTarget(target: MorphTarget): void;
  25829. /**
  25830. * Removes a target from the manager
  25831. * @param target defines the target to remove
  25832. */
  25833. removeTarget(target: MorphTarget): void;
  25834. /**
  25835. * Clone the current manager
  25836. * @returns a new MorphTargetManager
  25837. */
  25838. clone(): MorphTargetManager;
  25839. /**
  25840. * Serializes the current manager into a Serialization object
  25841. * @returns the serialized object
  25842. */
  25843. serialize(): any;
  25844. private _syncActiveTargets;
  25845. /**
  25846. * Syncrhonize the targets with all the meshes using this morph target manager
  25847. */
  25848. synchronize(): void;
  25849. /**
  25850. * Creates a new MorphTargetManager from serialized data
  25851. * @param serializationObject defines the serialized data
  25852. * @param scene defines the hosting scene
  25853. * @returns the new MorphTargetManager
  25854. */
  25855. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25856. }
  25857. }
  25858. declare module BABYLON {
  25859. /**
  25860. * Class used to represent a specific level of detail of a mesh
  25861. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25862. */
  25863. export class MeshLODLevel {
  25864. /** Defines the distance where this level should start being displayed */
  25865. distance: number;
  25866. /** Defines the mesh to use to render this level */
  25867. mesh: Nullable<Mesh>;
  25868. /**
  25869. * Creates a new LOD level
  25870. * @param distance defines the distance where this level should star being displayed
  25871. * @param mesh defines the mesh to use to render this level
  25872. */
  25873. constructor(
  25874. /** Defines the distance where this level should start being displayed */
  25875. distance: number,
  25876. /** Defines the mesh to use to render this level */
  25877. mesh: Nullable<Mesh>);
  25878. }
  25879. }
  25880. declare module BABYLON {
  25881. /**
  25882. * Mesh representing the gorund
  25883. */
  25884. export class GroundMesh extends Mesh {
  25885. /** If octree should be generated */
  25886. generateOctree: boolean;
  25887. private _heightQuads;
  25888. /** @hidden */
  25889. _subdivisionsX: number;
  25890. /** @hidden */
  25891. _subdivisionsY: number;
  25892. /** @hidden */
  25893. _width: number;
  25894. /** @hidden */
  25895. _height: number;
  25896. /** @hidden */
  25897. _minX: number;
  25898. /** @hidden */
  25899. _maxX: number;
  25900. /** @hidden */
  25901. _minZ: number;
  25902. /** @hidden */
  25903. _maxZ: number;
  25904. constructor(name: string, scene: Scene);
  25905. /**
  25906. * "GroundMesh"
  25907. * @returns "GroundMesh"
  25908. */
  25909. getClassName(): string;
  25910. /**
  25911. * The minimum of x and y subdivisions
  25912. */
  25913. get subdivisions(): number;
  25914. /**
  25915. * X subdivisions
  25916. */
  25917. get subdivisionsX(): number;
  25918. /**
  25919. * Y subdivisions
  25920. */
  25921. get subdivisionsY(): number;
  25922. /**
  25923. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25924. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25925. * @param chunksCount the number of subdivisions for x and y
  25926. * @param octreeBlocksSize (Default: 32)
  25927. */
  25928. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25929. /**
  25930. * Returns a height (y) value in the Worl system :
  25931. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25932. * @param x x coordinate
  25933. * @param z z coordinate
  25934. * @returns the ground y position if (x, z) are outside the ground surface.
  25935. */
  25936. getHeightAtCoordinates(x: number, z: number): number;
  25937. /**
  25938. * Returns a normalized vector (Vector3) orthogonal to the ground
  25939. * at the ground coordinates (x, z) expressed in the World system.
  25940. * @param x x coordinate
  25941. * @param z z coordinate
  25942. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25943. */
  25944. getNormalAtCoordinates(x: number, z: number): Vector3;
  25945. /**
  25946. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25947. * at the ground coordinates (x, z) expressed in the World system.
  25948. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25949. * @param x x coordinate
  25950. * @param z z coordinate
  25951. * @param ref vector to store the result
  25952. * @returns the GroundMesh.
  25953. */
  25954. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25955. /**
  25956. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25957. * if the ground has been updated.
  25958. * This can be used in the render loop.
  25959. * @returns the GroundMesh.
  25960. */
  25961. updateCoordinateHeights(): GroundMesh;
  25962. private _getFacetAt;
  25963. private _initHeightQuads;
  25964. private _computeHeightQuads;
  25965. /**
  25966. * Serializes this ground mesh
  25967. * @param serializationObject object to write serialization to
  25968. */
  25969. serialize(serializationObject: any): void;
  25970. /**
  25971. * Parses a serialized ground mesh
  25972. * @param parsedMesh the serialized mesh
  25973. * @param scene the scene to create the ground mesh in
  25974. * @returns the created ground mesh
  25975. */
  25976. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25977. }
  25978. }
  25979. declare module BABYLON {
  25980. /**
  25981. * Interface for Physics-Joint data
  25982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25983. */
  25984. export interface PhysicsJointData {
  25985. /**
  25986. * The main pivot of the joint
  25987. */
  25988. mainPivot?: Vector3;
  25989. /**
  25990. * The connected pivot of the joint
  25991. */
  25992. connectedPivot?: Vector3;
  25993. /**
  25994. * The main axis of the joint
  25995. */
  25996. mainAxis?: Vector3;
  25997. /**
  25998. * The connected axis of the joint
  25999. */
  26000. connectedAxis?: Vector3;
  26001. /**
  26002. * The collision of the joint
  26003. */
  26004. collision?: boolean;
  26005. /**
  26006. * Native Oimo/Cannon/Energy data
  26007. */
  26008. nativeParams?: any;
  26009. }
  26010. /**
  26011. * This is a holder class for the physics joint created by the physics plugin
  26012. * It holds a set of functions to control the underlying joint
  26013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26014. */
  26015. export class PhysicsJoint {
  26016. /**
  26017. * The type of the physics joint
  26018. */
  26019. type: number;
  26020. /**
  26021. * The data for the physics joint
  26022. */
  26023. jointData: PhysicsJointData;
  26024. private _physicsJoint;
  26025. protected _physicsPlugin: IPhysicsEnginePlugin;
  26026. /**
  26027. * Initializes the physics joint
  26028. * @param type The type of the physics joint
  26029. * @param jointData The data for the physics joint
  26030. */
  26031. constructor(
  26032. /**
  26033. * The type of the physics joint
  26034. */
  26035. type: number,
  26036. /**
  26037. * The data for the physics joint
  26038. */
  26039. jointData: PhysicsJointData);
  26040. /**
  26041. * Gets the physics joint
  26042. */
  26043. get physicsJoint(): any;
  26044. /**
  26045. * Sets the physics joint
  26046. */
  26047. set physicsJoint(newJoint: any);
  26048. /**
  26049. * Sets the physics plugin
  26050. */
  26051. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26052. /**
  26053. * Execute a function that is physics-plugin specific.
  26054. * @param {Function} func the function that will be executed.
  26055. * It accepts two parameters: the physics world and the physics joint
  26056. */
  26057. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26058. /**
  26059. * Distance-Joint type
  26060. */
  26061. static DistanceJoint: number;
  26062. /**
  26063. * Hinge-Joint type
  26064. */
  26065. static HingeJoint: number;
  26066. /**
  26067. * Ball-and-Socket joint type
  26068. */
  26069. static BallAndSocketJoint: number;
  26070. /**
  26071. * Wheel-Joint type
  26072. */
  26073. static WheelJoint: number;
  26074. /**
  26075. * Slider-Joint type
  26076. */
  26077. static SliderJoint: number;
  26078. /**
  26079. * Prismatic-Joint type
  26080. */
  26081. static PrismaticJoint: number;
  26082. /**
  26083. * Universal-Joint type
  26084. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26085. */
  26086. static UniversalJoint: number;
  26087. /**
  26088. * Hinge-Joint 2 type
  26089. */
  26090. static Hinge2Joint: number;
  26091. /**
  26092. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26093. */
  26094. static PointToPointJoint: number;
  26095. /**
  26096. * Spring-Joint type
  26097. */
  26098. static SpringJoint: number;
  26099. /**
  26100. * Lock-Joint type
  26101. */
  26102. static LockJoint: number;
  26103. }
  26104. /**
  26105. * A class representing a physics distance joint
  26106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26107. */
  26108. export class DistanceJoint extends PhysicsJoint {
  26109. /**
  26110. *
  26111. * @param jointData The data for the Distance-Joint
  26112. */
  26113. constructor(jointData: DistanceJointData);
  26114. /**
  26115. * Update the predefined distance.
  26116. * @param maxDistance The maximum preferred distance
  26117. * @param minDistance The minimum preferred distance
  26118. */
  26119. updateDistance(maxDistance: number, minDistance?: number): void;
  26120. }
  26121. /**
  26122. * Represents a Motor-Enabled Joint
  26123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26124. */
  26125. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26126. /**
  26127. * Initializes the Motor-Enabled Joint
  26128. * @param type The type of the joint
  26129. * @param jointData The physica joint data for the joint
  26130. */
  26131. constructor(type: number, jointData: PhysicsJointData);
  26132. /**
  26133. * Set the motor values.
  26134. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26135. * @param force the force to apply
  26136. * @param maxForce max force for this motor.
  26137. */
  26138. setMotor(force?: number, maxForce?: number): void;
  26139. /**
  26140. * Set the motor's limits.
  26141. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26142. * @param upperLimit The upper limit of the motor
  26143. * @param lowerLimit The lower limit of the motor
  26144. */
  26145. setLimit(upperLimit: number, lowerLimit?: number): void;
  26146. }
  26147. /**
  26148. * This class represents a single physics Hinge-Joint
  26149. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26150. */
  26151. export class HingeJoint extends MotorEnabledJoint {
  26152. /**
  26153. * Initializes the Hinge-Joint
  26154. * @param jointData The joint data for the Hinge-Joint
  26155. */
  26156. constructor(jointData: PhysicsJointData);
  26157. /**
  26158. * Set the motor values.
  26159. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26160. * @param {number} force the force to apply
  26161. * @param {number} maxForce max force for this motor.
  26162. */
  26163. setMotor(force?: number, maxForce?: number): void;
  26164. /**
  26165. * Set the motor's limits.
  26166. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26167. * @param upperLimit The upper limit of the motor
  26168. * @param lowerLimit The lower limit of the motor
  26169. */
  26170. setLimit(upperLimit: number, lowerLimit?: number): void;
  26171. }
  26172. /**
  26173. * This class represents a dual hinge physics joint (same as wheel joint)
  26174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26175. */
  26176. export class Hinge2Joint extends MotorEnabledJoint {
  26177. /**
  26178. * Initializes the Hinge2-Joint
  26179. * @param jointData The joint data for the Hinge2-Joint
  26180. */
  26181. constructor(jointData: PhysicsJointData);
  26182. /**
  26183. * Set the motor values.
  26184. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26185. * @param {number} targetSpeed the speed the motor is to reach
  26186. * @param {number} maxForce max force for this motor.
  26187. * @param {motorIndex} the motor's index, 0 or 1.
  26188. */
  26189. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26190. /**
  26191. * Set the motor limits.
  26192. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26193. * @param {number} upperLimit the upper limit
  26194. * @param {number} lowerLimit lower limit
  26195. * @param {motorIndex} the motor's index, 0 or 1.
  26196. */
  26197. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26198. }
  26199. /**
  26200. * Interface for a motor enabled joint
  26201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26202. */
  26203. export interface IMotorEnabledJoint {
  26204. /**
  26205. * Physics joint
  26206. */
  26207. physicsJoint: any;
  26208. /**
  26209. * Sets the motor of the motor-enabled joint
  26210. * @param force The force of the motor
  26211. * @param maxForce The maximum force of the motor
  26212. * @param motorIndex The index of the motor
  26213. */
  26214. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26215. /**
  26216. * Sets the limit of the motor
  26217. * @param upperLimit The upper limit of the motor
  26218. * @param lowerLimit The lower limit of the motor
  26219. * @param motorIndex The index of the motor
  26220. */
  26221. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26222. }
  26223. /**
  26224. * Joint data for a Distance-Joint
  26225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26226. */
  26227. export interface DistanceJointData extends PhysicsJointData {
  26228. /**
  26229. * Max distance the 2 joint objects can be apart
  26230. */
  26231. maxDistance: number;
  26232. }
  26233. /**
  26234. * Joint data from a spring joint
  26235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26236. */
  26237. export interface SpringJointData extends PhysicsJointData {
  26238. /**
  26239. * Length of the spring
  26240. */
  26241. length: number;
  26242. /**
  26243. * Stiffness of the spring
  26244. */
  26245. stiffness: number;
  26246. /**
  26247. * Damping of the spring
  26248. */
  26249. damping: number;
  26250. /** this callback will be called when applying the force to the impostors. */
  26251. forceApplicationCallback: () => void;
  26252. }
  26253. }
  26254. declare module BABYLON {
  26255. /**
  26256. * Holds the data for the raycast result
  26257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26258. */
  26259. export class PhysicsRaycastResult {
  26260. private _hasHit;
  26261. private _hitDistance;
  26262. private _hitNormalWorld;
  26263. private _hitPointWorld;
  26264. private _rayFromWorld;
  26265. private _rayToWorld;
  26266. /**
  26267. * Gets if there was a hit
  26268. */
  26269. get hasHit(): boolean;
  26270. /**
  26271. * Gets the distance from the hit
  26272. */
  26273. get hitDistance(): number;
  26274. /**
  26275. * Gets the hit normal/direction in the world
  26276. */
  26277. get hitNormalWorld(): Vector3;
  26278. /**
  26279. * Gets the hit point in the world
  26280. */
  26281. get hitPointWorld(): Vector3;
  26282. /**
  26283. * Gets the ray "start point" of the ray in the world
  26284. */
  26285. get rayFromWorld(): Vector3;
  26286. /**
  26287. * Gets the ray "end point" of the ray in the world
  26288. */
  26289. get rayToWorld(): Vector3;
  26290. /**
  26291. * Sets the hit data (normal & point in world space)
  26292. * @param hitNormalWorld defines the normal in world space
  26293. * @param hitPointWorld defines the point in world space
  26294. */
  26295. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26296. /**
  26297. * Sets the distance from the start point to the hit point
  26298. * @param distance
  26299. */
  26300. setHitDistance(distance: number): void;
  26301. /**
  26302. * Calculates the distance manually
  26303. */
  26304. calculateHitDistance(): void;
  26305. /**
  26306. * Resets all the values to default
  26307. * @param from The from point on world space
  26308. * @param to The to point on world space
  26309. */
  26310. reset(from?: Vector3, to?: Vector3): void;
  26311. }
  26312. /**
  26313. * Interface for the size containing width and height
  26314. */
  26315. interface IXYZ {
  26316. /**
  26317. * X
  26318. */
  26319. x: number;
  26320. /**
  26321. * Y
  26322. */
  26323. y: number;
  26324. /**
  26325. * Z
  26326. */
  26327. z: number;
  26328. }
  26329. }
  26330. declare module BABYLON {
  26331. /**
  26332. * Interface used to describe a physics joint
  26333. */
  26334. export interface PhysicsImpostorJoint {
  26335. /** Defines the main impostor to which the joint is linked */
  26336. mainImpostor: PhysicsImpostor;
  26337. /** Defines the impostor that is connected to the main impostor using this joint */
  26338. connectedImpostor: PhysicsImpostor;
  26339. /** Defines the joint itself */
  26340. joint: PhysicsJoint;
  26341. }
  26342. /** @hidden */
  26343. export interface IPhysicsEnginePlugin {
  26344. world: any;
  26345. name: string;
  26346. setGravity(gravity: Vector3): void;
  26347. setTimeStep(timeStep: number): void;
  26348. getTimeStep(): number;
  26349. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26350. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26351. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26352. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26353. removePhysicsBody(impostor: PhysicsImpostor): void;
  26354. generateJoint(joint: PhysicsImpostorJoint): void;
  26355. removeJoint(joint: PhysicsImpostorJoint): void;
  26356. isSupported(): boolean;
  26357. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26358. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26359. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26360. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26361. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26362. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26363. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26364. getBodyMass(impostor: PhysicsImpostor): number;
  26365. getBodyFriction(impostor: PhysicsImpostor): number;
  26366. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26367. getBodyRestitution(impostor: PhysicsImpostor): number;
  26368. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26369. getBodyPressure?(impostor: PhysicsImpostor): number;
  26370. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26371. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26372. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26373. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26374. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26375. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26376. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26377. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26378. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26379. sleepBody(impostor: PhysicsImpostor): void;
  26380. wakeUpBody(impostor: PhysicsImpostor): void;
  26381. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26382. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26383. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26384. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26385. getRadius(impostor: PhysicsImpostor): number;
  26386. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26387. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26388. dispose(): void;
  26389. }
  26390. /**
  26391. * Interface used to define a physics engine
  26392. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26393. */
  26394. export interface IPhysicsEngine {
  26395. /**
  26396. * Gets the gravity vector used by the simulation
  26397. */
  26398. gravity: Vector3;
  26399. /**
  26400. * Sets the gravity vector used by the simulation
  26401. * @param gravity defines the gravity vector to use
  26402. */
  26403. setGravity(gravity: Vector3): void;
  26404. /**
  26405. * Set the time step of the physics engine.
  26406. * Default is 1/60.
  26407. * To slow it down, enter 1/600 for example.
  26408. * To speed it up, 1/30
  26409. * @param newTimeStep the new timestep to apply to this world.
  26410. */
  26411. setTimeStep(newTimeStep: number): void;
  26412. /**
  26413. * Get the time step of the physics engine.
  26414. * @returns the current time step
  26415. */
  26416. getTimeStep(): number;
  26417. /**
  26418. * Set the sub time step of the physics engine.
  26419. * Default is 0 meaning there is no sub steps
  26420. * To increase physics resolution precision, set a small value (like 1 ms)
  26421. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26422. */
  26423. setSubTimeStep(subTimeStep: number): void;
  26424. /**
  26425. * Get the sub time step of the physics engine.
  26426. * @returns the current sub time step
  26427. */
  26428. getSubTimeStep(): number;
  26429. /**
  26430. * Release all resources
  26431. */
  26432. dispose(): void;
  26433. /**
  26434. * Gets the name of the current physics plugin
  26435. * @returns the name of the plugin
  26436. */
  26437. getPhysicsPluginName(): string;
  26438. /**
  26439. * Adding a new impostor for the impostor tracking.
  26440. * This will be done by the impostor itself.
  26441. * @param impostor the impostor to add
  26442. */
  26443. addImpostor(impostor: PhysicsImpostor): void;
  26444. /**
  26445. * Remove an impostor from the engine.
  26446. * This impostor and its mesh will not longer be updated by the physics engine.
  26447. * @param impostor the impostor to remove
  26448. */
  26449. removeImpostor(impostor: PhysicsImpostor): void;
  26450. /**
  26451. * Add a joint to the physics engine
  26452. * @param mainImpostor defines the main impostor to which the joint is added.
  26453. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26454. * @param joint defines the joint that will connect both impostors.
  26455. */
  26456. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26457. /**
  26458. * Removes a joint from the simulation
  26459. * @param mainImpostor defines the impostor used with the joint
  26460. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26461. * @param joint defines the joint to remove
  26462. */
  26463. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26464. /**
  26465. * Gets the current plugin used to run the simulation
  26466. * @returns current plugin
  26467. */
  26468. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26469. /**
  26470. * Gets the list of physic impostors
  26471. * @returns an array of PhysicsImpostor
  26472. */
  26473. getImpostors(): Array<PhysicsImpostor>;
  26474. /**
  26475. * Gets the impostor for a physics enabled object
  26476. * @param object defines the object impersonated by the impostor
  26477. * @returns the PhysicsImpostor or null if not found
  26478. */
  26479. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26480. /**
  26481. * Gets the impostor for a physics body object
  26482. * @param body defines physics body used by the impostor
  26483. * @returns the PhysicsImpostor or null if not found
  26484. */
  26485. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26486. /**
  26487. * Does a raycast in the physics world
  26488. * @param from when should the ray start?
  26489. * @param to when should the ray end?
  26490. * @returns PhysicsRaycastResult
  26491. */
  26492. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26493. /**
  26494. * Called by the scene. No need to call it.
  26495. * @param delta defines the timespam between frames
  26496. */
  26497. _step(delta: number): void;
  26498. }
  26499. }
  26500. declare module BABYLON {
  26501. /**
  26502. * The interface for the physics imposter parameters
  26503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26504. */
  26505. export interface PhysicsImpostorParameters {
  26506. /**
  26507. * The mass of the physics imposter
  26508. */
  26509. mass: number;
  26510. /**
  26511. * The friction of the physics imposter
  26512. */
  26513. friction?: number;
  26514. /**
  26515. * The coefficient of restitution of the physics imposter
  26516. */
  26517. restitution?: number;
  26518. /**
  26519. * The native options of the physics imposter
  26520. */
  26521. nativeOptions?: any;
  26522. /**
  26523. * Specifies if the parent should be ignored
  26524. */
  26525. ignoreParent?: boolean;
  26526. /**
  26527. * Specifies if bi-directional transformations should be disabled
  26528. */
  26529. disableBidirectionalTransformation?: boolean;
  26530. /**
  26531. * The pressure inside the physics imposter, soft object only
  26532. */
  26533. pressure?: number;
  26534. /**
  26535. * The stiffness the physics imposter, soft object only
  26536. */
  26537. stiffness?: number;
  26538. /**
  26539. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26540. */
  26541. velocityIterations?: number;
  26542. /**
  26543. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26544. */
  26545. positionIterations?: number;
  26546. /**
  26547. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26548. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26549. * Add to fix multiple points
  26550. */
  26551. fixedPoints?: number;
  26552. /**
  26553. * The collision margin around a soft object
  26554. */
  26555. margin?: number;
  26556. /**
  26557. * The collision margin around a soft object
  26558. */
  26559. damping?: number;
  26560. /**
  26561. * The path for a rope based on an extrusion
  26562. */
  26563. path?: any;
  26564. /**
  26565. * The shape of an extrusion used for a rope based on an extrusion
  26566. */
  26567. shape?: any;
  26568. }
  26569. /**
  26570. * Interface for a physics-enabled object
  26571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26572. */
  26573. export interface IPhysicsEnabledObject {
  26574. /**
  26575. * The position of the physics-enabled object
  26576. */
  26577. position: Vector3;
  26578. /**
  26579. * The rotation of the physics-enabled object
  26580. */
  26581. rotationQuaternion: Nullable<Quaternion>;
  26582. /**
  26583. * The scale of the physics-enabled object
  26584. */
  26585. scaling: Vector3;
  26586. /**
  26587. * The rotation of the physics-enabled object
  26588. */
  26589. rotation?: Vector3;
  26590. /**
  26591. * The parent of the physics-enabled object
  26592. */
  26593. parent?: any;
  26594. /**
  26595. * The bounding info of the physics-enabled object
  26596. * @returns The bounding info of the physics-enabled object
  26597. */
  26598. getBoundingInfo(): BoundingInfo;
  26599. /**
  26600. * Computes the world matrix
  26601. * @param force Specifies if the world matrix should be computed by force
  26602. * @returns A world matrix
  26603. */
  26604. computeWorldMatrix(force: boolean): Matrix;
  26605. /**
  26606. * Gets the world matrix
  26607. * @returns A world matrix
  26608. */
  26609. getWorldMatrix?(): Matrix;
  26610. /**
  26611. * Gets the child meshes
  26612. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26613. * @returns An array of abstract meshes
  26614. */
  26615. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26616. /**
  26617. * Gets the vertex data
  26618. * @param kind The type of vertex data
  26619. * @returns A nullable array of numbers, or a float32 array
  26620. */
  26621. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26622. /**
  26623. * Gets the indices from the mesh
  26624. * @returns A nullable array of index arrays
  26625. */
  26626. getIndices?(): Nullable<IndicesArray>;
  26627. /**
  26628. * Gets the scene from the mesh
  26629. * @returns the indices array or null
  26630. */
  26631. getScene?(): Scene;
  26632. /**
  26633. * Gets the absolute position from the mesh
  26634. * @returns the absolute position
  26635. */
  26636. getAbsolutePosition(): Vector3;
  26637. /**
  26638. * Gets the absolute pivot point from the mesh
  26639. * @returns the absolute pivot point
  26640. */
  26641. getAbsolutePivotPoint(): Vector3;
  26642. /**
  26643. * Rotates the mesh
  26644. * @param axis The axis of rotation
  26645. * @param amount The amount of rotation
  26646. * @param space The space of the rotation
  26647. * @returns The rotation transform node
  26648. */
  26649. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26650. /**
  26651. * Translates the mesh
  26652. * @param axis The axis of translation
  26653. * @param distance The distance of translation
  26654. * @param space The space of the translation
  26655. * @returns The transform node
  26656. */
  26657. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26658. /**
  26659. * Sets the absolute position of the mesh
  26660. * @param absolutePosition The absolute position of the mesh
  26661. * @returns The transform node
  26662. */
  26663. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26664. /**
  26665. * Gets the class name of the mesh
  26666. * @returns The class name
  26667. */
  26668. getClassName(): string;
  26669. }
  26670. /**
  26671. * Represents a physics imposter
  26672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26673. */
  26674. export class PhysicsImpostor {
  26675. /**
  26676. * The physics-enabled object used as the physics imposter
  26677. */
  26678. object: IPhysicsEnabledObject;
  26679. /**
  26680. * The type of the physics imposter
  26681. */
  26682. type: number;
  26683. private _options;
  26684. private _scene?;
  26685. /**
  26686. * The default object size of the imposter
  26687. */
  26688. static DEFAULT_OBJECT_SIZE: Vector3;
  26689. /**
  26690. * The identity quaternion of the imposter
  26691. */
  26692. static IDENTITY_QUATERNION: Quaternion;
  26693. /** @hidden */
  26694. _pluginData: any;
  26695. private _physicsEngine;
  26696. private _physicsBody;
  26697. private _bodyUpdateRequired;
  26698. private _onBeforePhysicsStepCallbacks;
  26699. private _onAfterPhysicsStepCallbacks;
  26700. /** @hidden */
  26701. _onPhysicsCollideCallbacks: Array<{
  26702. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26703. otherImpostors: Array<PhysicsImpostor>;
  26704. }>;
  26705. private _deltaPosition;
  26706. private _deltaRotation;
  26707. private _deltaRotationConjugated;
  26708. /** @hidden */
  26709. _isFromLine: boolean;
  26710. private _parent;
  26711. private _isDisposed;
  26712. private static _tmpVecs;
  26713. private static _tmpQuat;
  26714. /**
  26715. * Specifies if the physics imposter is disposed
  26716. */
  26717. get isDisposed(): boolean;
  26718. /**
  26719. * Gets the mass of the physics imposter
  26720. */
  26721. get mass(): number;
  26722. set mass(value: number);
  26723. /**
  26724. * Gets the coefficient of friction
  26725. */
  26726. get friction(): number;
  26727. /**
  26728. * Sets the coefficient of friction
  26729. */
  26730. set friction(value: number);
  26731. /**
  26732. * Gets the coefficient of restitution
  26733. */
  26734. get restitution(): number;
  26735. /**
  26736. * Sets the coefficient of restitution
  26737. */
  26738. set restitution(value: number);
  26739. /**
  26740. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26741. */
  26742. get pressure(): number;
  26743. /**
  26744. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26745. */
  26746. set pressure(value: number);
  26747. /**
  26748. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26749. */
  26750. get stiffness(): number;
  26751. /**
  26752. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26753. */
  26754. set stiffness(value: number);
  26755. /**
  26756. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26757. */
  26758. get velocityIterations(): number;
  26759. /**
  26760. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26761. */
  26762. set velocityIterations(value: number);
  26763. /**
  26764. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26765. */
  26766. get positionIterations(): number;
  26767. /**
  26768. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26769. */
  26770. set positionIterations(value: number);
  26771. /**
  26772. * The unique id of the physics imposter
  26773. * set by the physics engine when adding this impostor to the array
  26774. */
  26775. uniqueId: number;
  26776. /**
  26777. * @hidden
  26778. */
  26779. soft: boolean;
  26780. /**
  26781. * @hidden
  26782. */
  26783. segments: number;
  26784. private _joints;
  26785. /**
  26786. * Initializes the physics imposter
  26787. * @param object The physics-enabled object used as the physics imposter
  26788. * @param type The type of the physics imposter
  26789. * @param _options The options for the physics imposter
  26790. * @param _scene The Babylon scene
  26791. */
  26792. constructor(
  26793. /**
  26794. * The physics-enabled object used as the physics imposter
  26795. */
  26796. object: IPhysicsEnabledObject,
  26797. /**
  26798. * The type of the physics imposter
  26799. */
  26800. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26801. /**
  26802. * This function will completly initialize this impostor.
  26803. * It will create a new body - but only if this mesh has no parent.
  26804. * If it has, this impostor will not be used other than to define the impostor
  26805. * of the child mesh.
  26806. * @hidden
  26807. */
  26808. _init(): void;
  26809. private _getPhysicsParent;
  26810. /**
  26811. * Should a new body be generated.
  26812. * @returns boolean specifying if body initialization is required
  26813. */
  26814. isBodyInitRequired(): boolean;
  26815. /**
  26816. * Sets the updated scaling
  26817. * @param updated Specifies if the scaling is updated
  26818. */
  26819. setScalingUpdated(): void;
  26820. /**
  26821. * Force a regeneration of this or the parent's impostor's body.
  26822. * Use under cautious - This will remove all joints already implemented.
  26823. */
  26824. forceUpdate(): void;
  26825. /**
  26826. * Gets the body that holds this impostor. Either its own, or its parent.
  26827. */
  26828. get physicsBody(): any;
  26829. /**
  26830. * Get the parent of the physics imposter
  26831. * @returns Physics imposter or null
  26832. */
  26833. get parent(): Nullable<PhysicsImpostor>;
  26834. /**
  26835. * Sets the parent of the physics imposter
  26836. */
  26837. set parent(value: Nullable<PhysicsImpostor>);
  26838. /**
  26839. * Set the physics body. Used mainly by the physics engine/plugin
  26840. */
  26841. set physicsBody(physicsBody: any);
  26842. /**
  26843. * Resets the update flags
  26844. */
  26845. resetUpdateFlags(): void;
  26846. /**
  26847. * Gets the object extend size
  26848. * @returns the object extend size
  26849. */
  26850. getObjectExtendSize(): Vector3;
  26851. /**
  26852. * Gets the object center
  26853. * @returns The object center
  26854. */
  26855. getObjectCenter(): Vector3;
  26856. /**
  26857. * Get a specific parameter from the options parameters
  26858. * @param paramName The object parameter name
  26859. * @returns The object parameter
  26860. */
  26861. getParam(paramName: string): any;
  26862. /**
  26863. * Sets a specific parameter in the options given to the physics plugin
  26864. * @param paramName The parameter name
  26865. * @param value The value of the parameter
  26866. */
  26867. setParam(paramName: string, value: number): void;
  26868. /**
  26869. * Specifically change the body's mass option. Won't recreate the physics body object
  26870. * @param mass The mass of the physics imposter
  26871. */
  26872. setMass(mass: number): void;
  26873. /**
  26874. * Gets the linear velocity
  26875. * @returns linear velocity or null
  26876. */
  26877. getLinearVelocity(): Nullable<Vector3>;
  26878. /**
  26879. * Sets the linear velocity
  26880. * @param velocity linear velocity or null
  26881. */
  26882. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26883. /**
  26884. * Gets the angular velocity
  26885. * @returns angular velocity or null
  26886. */
  26887. getAngularVelocity(): Nullable<Vector3>;
  26888. /**
  26889. * Sets the angular velocity
  26890. * @param velocity The velocity or null
  26891. */
  26892. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26893. /**
  26894. * Execute a function with the physics plugin native code
  26895. * Provide a function the will have two variables - the world object and the physics body object
  26896. * @param func The function to execute with the physics plugin native code
  26897. */
  26898. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26899. /**
  26900. * Register a function that will be executed before the physics world is stepping forward
  26901. * @param func The function to execute before the physics world is stepped forward
  26902. */
  26903. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26904. /**
  26905. * Unregister a function that will be executed before the physics world is stepping forward
  26906. * @param func The function to execute before the physics world is stepped forward
  26907. */
  26908. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26909. /**
  26910. * Register a function that will be executed after the physics step
  26911. * @param func The function to execute after physics step
  26912. */
  26913. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26914. /**
  26915. * Unregisters a function that will be executed after the physics step
  26916. * @param func The function to execute after physics step
  26917. */
  26918. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26919. /**
  26920. * register a function that will be executed when this impostor collides against a different body
  26921. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26922. * @param func Callback that is executed on collision
  26923. */
  26924. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26925. /**
  26926. * Unregisters the physics imposter on contact
  26927. * @param collideAgainst The physics object to collide against
  26928. * @param func Callback to execute on collision
  26929. */
  26930. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26931. private _tmpQuat;
  26932. private _tmpQuat2;
  26933. /**
  26934. * Get the parent rotation
  26935. * @returns The parent rotation
  26936. */
  26937. getParentsRotation(): Quaternion;
  26938. /**
  26939. * this function is executed by the physics engine.
  26940. */
  26941. beforeStep: () => void;
  26942. /**
  26943. * this function is executed by the physics engine
  26944. */
  26945. afterStep: () => void;
  26946. /**
  26947. * Legacy collision detection event support
  26948. */
  26949. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26950. /**
  26951. * event and body object due to cannon's event-based architecture.
  26952. */
  26953. onCollide: (e: {
  26954. body: any;
  26955. }) => void;
  26956. /**
  26957. * Apply a force
  26958. * @param force The force to apply
  26959. * @param contactPoint The contact point for the force
  26960. * @returns The physics imposter
  26961. */
  26962. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26963. /**
  26964. * Apply an impulse
  26965. * @param force The impulse force
  26966. * @param contactPoint The contact point for the impulse force
  26967. * @returns The physics imposter
  26968. */
  26969. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26970. /**
  26971. * A help function to create a joint
  26972. * @param otherImpostor A physics imposter used to create a joint
  26973. * @param jointType The type of joint
  26974. * @param jointData The data for the joint
  26975. * @returns The physics imposter
  26976. */
  26977. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26978. /**
  26979. * Add a joint to this impostor with a different impostor
  26980. * @param otherImpostor A physics imposter used to add a joint
  26981. * @param joint The joint to add
  26982. * @returns The physics imposter
  26983. */
  26984. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26985. /**
  26986. * Add an anchor to a cloth impostor
  26987. * @param otherImpostor rigid impostor to anchor to
  26988. * @param width ratio across width from 0 to 1
  26989. * @param height ratio up height from 0 to 1
  26990. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  26991. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  26992. * @returns impostor the soft imposter
  26993. */
  26994. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26995. /**
  26996. * Add a hook to a rope impostor
  26997. * @param otherImpostor rigid impostor to anchor to
  26998. * @param length ratio across rope from 0 to 1
  26999. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27000. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27001. * @returns impostor the rope imposter
  27002. */
  27003. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27004. /**
  27005. * Will keep this body still, in a sleep mode.
  27006. * @returns the physics imposter
  27007. */
  27008. sleep(): PhysicsImpostor;
  27009. /**
  27010. * Wake the body up.
  27011. * @returns The physics imposter
  27012. */
  27013. wakeUp(): PhysicsImpostor;
  27014. /**
  27015. * Clones the physics imposter
  27016. * @param newObject The physics imposter clones to this physics-enabled object
  27017. * @returns A nullable physics imposter
  27018. */
  27019. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27020. /**
  27021. * Disposes the physics imposter
  27022. */
  27023. dispose(): void;
  27024. /**
  27025. * Sets the delta position
  27026. * @param position The delta position amount
  27027. */
  27028. setDeltaPosition(position: Vector3): void;
  27029. /**
  27030. * Sets the delta rotation
  27031. * @param rotation The delta rotation amount
  27032. */
  27033. setDeltaRotation(rotation: Quaternion): void;
  27034. /**
  27035. * Gets the box size of the physics imposter and stores the result in the input parameter
  27036. * @param result Stores the box size
  27037. * @returns The physics imposter
  27038. */
  27039. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27040. /**
  27041. * Gets the radius of the physics imposter
  27042. * @returns Radius of the physics imposter
  27043. */
  27044. getRadius(): number;
  27045. /**
  27046. * Sync a bone with this impostor
  27047. * @param bone The bone to sync to the impostor.
  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. */
  27053. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27054. /**
  27055. * Sync impostor to a bone
  27056. * @param bone The bone that the impostor will be synced to.
  27057. * @param boneMesh The mesh that the bone is influencing.
  27058. * @param jointPivot The pivot of the joint / bone in local space.
  27059. * @param distToJoint Optional distance from the impostor to the joint.
  27060. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27061. * @param boneAxis Optional vector3 axis the bone is aligned with
  27062. */
  27063. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27064. /**
  27065. * No-Imposter type
  27066. */
  27067. static NoImpostor: number;
  27068. /**
  27069. * Sphere-Imposter type
  27070. */
  27071. static SphereImpostor: number;
  27072. /**
  27073. * Box-Imposter type
  27074. */
  27075. static BoxImpostor: number;
  27076. /**
  27077. * Plane-Imposter type
  27078. */
  27079. static PlaneImpostor: number;
  27080. /**
  27081. * Mesh-imposter type
  27082. */
  27083. static MeshImpostor: number;
  27084. /**
  27085. * Capsule-Impostor type (Ammo.js plugin only)
  27086. */
  27087. static CapsuleImpostor: number;
  27088. /**
  27089. * Cylinder-Imposter type
  27090. */
  27091. static CylinderImpostor: number;
  27092. /**
  27093. * Particle-Imposter type
  27094. */
  27095. static ParticleImpostor: number;
  27096. /**
  27097. * Heightmap-Imposter type
  27098. */
  27099. static HeightmapImpostor: number;
  27100. /**
  27101. * ConvexHull-Impostor type (Ammo.js plugin only)
  27102. */
  27103. static ConvexHullImpostor: number;
  27104. /**
  27105. * Custom-Imposter type (Ammo.js plugin only)
  27106. */
  27107. static CustomImpostor: number;
  27108. /**
  27109. * Rope-Imposter type
  27110. */
  27111. static RopeImpostor: number;
  27112. /**
  27113. * Cloth-Imposter type
  27114. */
  27115. static ClothImpostor: number;
  27116. /**
  27117. * Softbody-Imposter type
  27118. */
  27119. static SoftbodyImpostor: number;
  27120. }
  27121. }
  27122. declare module BABYLON {
  27123. /**
  27124. * @hidden
  27125. **/
  27126. export class _CreationDataStorage {
  27127. closePath?: boolean;
  27128. closeArray?: boolean;
  27129. idx: number[];
  27130. dashSize: number;
  27131. gapSize: number;
  27132. path3D: Path3D;
  27133. pathArray: Vector3[][];
  27134. arc: number;
  27135. radius: number;
  27136. cap: number;
  27137. tessellation: number;
  27138. }
  27139. /**
  27140. * @hidden
  27141. **/
  27142. class _InstanceDataStorage {
  27143. visibleInstances: any;
  27144. batchCache: _InstancesBatch;
  27145. instancesBufferSize: number;
  27146. instancesBuffer: Nullable<Buffer>;
  27147. instancesData: Float32Array;
  27148. overridenInstanceCount: number;
  27149. isFrozen: boolean;
  27150. previousBatch: Nullable<_InstancesBatch>;
  27151. hardwareInstancedRendering: boolean;
  27152. sideOrientation: number;
  27153. manualUpdate: boolean;
  27154. }
  27155. /**
  27156. * @hidden
  27157. **/
  27158. export class _InstancesBatch {
  27159. mustReturn: boolean;
  27160. visibleInstances: Nullable<InstancedMesh[]>[];
  27161. renderSelf: boolean[];
  27162. hardwareInstancedRendering: boolean[];
  27163. }
  27164. /**
  27165. * Class used to represent renderable models
  27166. */
  27167. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27168. /**
  27169. * Mesh side orientation : usually the external or front surface
  27170. */
  27171. static readonly FRONTSIDE: number;
  27172. /**
  27173. * Mesh side orientation : usually the internal or back surface
  27174. */
  27175. static readonly BACKSIDE: number;
  27176. /**
  27177. * Mesh side orientation : both internal and external or front and back surfaces
  27178. */
  27179. static readonly DOUBLESIDE: number;
  27180. /**
  27181. * Mesh side orientation : by default, `FRONTSIDE`
  27182. */
  27183. static readonly DEFAULTSIDE: number;
  27184. /**
  27185. * Mesh cap setting : no cap
  27186. */
  27187. static readonly NO_CAP: number;
  27188. /**
  27189. * Mesh cap setting : one cap at the beginning of the mesh
  27190. */
  27191. static readonly CAP_START: number;
  27192. /**
  27193. * Mesh cap setting : one cap at the end of the mesh
  27194. */
  27195. static readonly CAP_END: number;
  27196. /**
  27197. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27198. */
  27199. static readonly CAP_ALL: number;
  27200. /**
  27201. * Mesh pattern setting : no flip or rotate
  27202. */
  27203. static readonly NO_FLIP: number;
  27204. /**
  27205. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27206. */
  27207. static readonly FLIP_TILE: number;
  27208. /**
  27209. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27210. */
  27211. static readonly ROTATE_TILE: number;
  27212. /**
  27213. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27214. */
  27215. static readonly FLIP_ROW: number;
  27216. /**
  27217. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27218. */
  27219. static readonly ROTATE_ROW: number;
  27220. /**
  27221. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27222. */
  27223. static readonly FLIP_N_ROTATE_TILE: number;
  27224. /**
  27225. * Mesh pattern setting : rotate pattern and rotate
  27226. */
  27227. static readonly FLIP_N_ROTATE_ROW: number;
  27228. /**
  27229. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27230. */
  27231. static readonly CENTER: number;
  27232. /**
  27233. * Mesh tile positioning : part tiles on left
  27234. */
  27235. static readonly LEFT: number;
  27236. /**
  27237. * Mesh tile positioning : part tiles on right
  27238. */
  27239. static readonly RIGHT: number;
  27240. /**
  27241. * Mesh tile positioning : part tiles on top
  27242. */
  27243. static readonly TOP: number;
  27244. /**
  27245. * Mesh tile positioning : part tiles on bottom
  27246. */
  27247. static readonly BOTTOM: number;
  27248. /**
  27249. * Gets the default side orientation.
  27250. * @param orientation the orientation to value to attempt to get
  27251. * @returns the default orientation
  27252. * @hidden
  27253. */
  27254. static _GetDefaultSideOrientation(orientation?: number): number;
  27255. private _internalMeshDataInfo;
  27256. /**
  27257. * An event triggered before rendering the mesh
  27258. */
  27259. get onBeforeRenderObservable(): Observable<Mesh>;
  27260. /**
  27261. * An event triggered before binding the mesh
  27262. */
  27263. get onBeforeBindObservable(): Observable<Mesh>;
  27264. /**
  27265. * An event triggered after rendering the mesh
  27266. */
  27267. get onAfterRenderObservable(): Observable<Mesh>;
  27268. /**
  27269. * An event triggered before drawing the mesh
  27270. */
  27271. get onBeforeDrawObservable(): Observable<Mesh>;
  27272. private _onBeforeDrawObserver;
  27273. /**
  27274. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27275. */
  27276. set onBeforeDraw(callback: () => void);
  27277. get hasInstances(): boolean;
  27278. /**
  27279. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27280. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27281. */
  27282. delayLoadState: number;
  27283. /**
  27284. * Gets the list of instances created from this mesh
  27285. * it is not supposed to be modified manually.
  27286. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27287. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27288. */
  27289. instances: InstancedMesh[];
  27290. /**
  27291. * Gets the file containing delay loading data for this mesh
  27292. */
  27293. delayLoadingFile: string;
  27294. /** @hidden */
  27295. _binaryInfo: any;
  27296. /**
  27297. * User defined function used to change how LOD level selection is done
  27298. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27299. */
  27300. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27301. /**
  27302. * Gets or sets the morph target manager
  27303. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27304. */
  27305. get morphTargetManager(): Nullable<MorphTargetManager>;
  27306. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27307. /** @hidden */
  27308. _creationDataStorage: Nullable<_CreationDataStorage>;
  27309. /** @hidden */
  27310. _geometry: Nullable<Geometry>;
  27311. /** @hidden */
  27312. _delayInfo: Array<string>;
  27313. /** @hidden */
  27314. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27315. /** @hidden */
  27316. _instanceDataStorage: _InstanceDataStorage;
  27317. private _effectiveMaterial;
  27318. /** @hidden */
  27319. _shouldGenerateFlatShading: boolean;
  27320. /** @hidden */
  27321. _originalBuilderSideOrientation: number;
  27322. /**
  27323. * Use this property to change the original side orientation defined at construction time
  27324. */
  27325. overrideMaterialSideOrientation: Nullable<number>;
  27326. /**
  27327. * Gets the source mesh (the one used to clone this one from)
  27328. */
  27329. get source(): Nullable<Mesh>;
  27330. /**
  27331. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27332. */
  27333. get isUnIndexed(): boolean;
  27334. set isUnIndexed(value: boolean);
  27335. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27336. get worldMatrixInstancedBuffer(): Float32Array;
  27337. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27338. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27339. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27340. /**
  27341. * @constructor
  27342. * @param name The value used by scene.getMeshByName() to do a lookup.
  27343. * @param scene The scene to add this mesh to.
  27344. * @param parent The parent of this mesh, if it has one
  27345. * @param source An optional Mesh from which geometry is shared, cloned.
  27346. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27347. * When false, achieved by calling a clone(), also passing False.
  27348. * This will make creation of children, recursive.
  27349. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27350. */
  27351. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27352. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27353. doNotInstantiate: boolean;
  27354. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27355. /**
  27356. * Gets the class name
  27357. * @returns the string "Mesh".
  27358. */
  27359. getClassName(): string;
  27360. /** @hidden */
  27361. get _isMesh(): boolean;
  27362. /**
  27363. * Returns a description of this mesh
  27364. * @param fullDetails define if full details about this mesh must be used
  27365. * @returns a descriptive string representing this mesh
  27366. */
  27367. toString(fullDetails?: boolean): string;
  27368. /** @hidden */
  27369. _unBindEffect(): void;
  27370. /**
  27371. * Gets a boolean indicating if this mesh has LOD
  27372. */
  27373. get hasLODLevels(): boolean;
  27374. /**
  27375. * Gets the list of MeshLODLevel associated with the current mesh
  27376. * @returns an array of MeshLODLevel
  27377. */
  27378. getLODLevels(): MeshLODLevel[];
  27379. private _sortLODLevels;
  27380. /**
  27381. * Add a mesh as LOD level triggered at the given distance.
  27382. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27383. * @param distance The distance from the center of the object to show this level
  27384. * @param mesh The mesh to be added as LOD level (can be null)
  27385. * @return This mesh (for chaining)
  27386. */
  27387. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27388. /**
  27389. * Returns the LOD level mesh at the passed distance or null if not found.
  27390. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27391. * @param distance The distance from the center of the object to show this level
  27392. * @returns a Mesh or `null`
  27393. */
  27394. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27395. /**
  27396. * Remove a mesh from the LOD array
  27397. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27398. * @param mesh defines the mesh to be removed
  27399. * @return This mesh (for chaining)
  27400. */
  27401. removeLODLevel(mesh: Mesh): Mesh;
  27402. /**
  27403. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27404. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27405. * @param camera defines the camera to use to compute distance
  27406. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27407. * @return This mesh (for chaining)
  27408. */
  27409. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27410. /**
  27411. * Gets the mesh internal Geometry object
  27412. */
  27413. get geometry(): Nullable<Geometry>;
  27414. /**
  27415. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27416. * @returns the total number of vertices
  27417. */
  27418. getTotalVertices(): number;
  27419. /**
  27420. * Returns the content of an associated vertex buffer
  27421. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27422. * - VertexBuffer.PositionKind
  27423. * - VertexBuffer.UVKind
  27424. * - VertexBuffer.UV2Kind
  27425. * - VertexBuffer.UV3Kind
  27426. * - VertexBuffer.UV4Kind
  27427. * - VertexBuffer.UV5Kind
  27428. * - VertexBuffer.UV6Kind
  27429. * - VertexBuffer.ColorKind
  27430. * - VertexBuffer.MatricesIndicesKind
  27431. * - VertexBuffer.MatricesIndicesExtraKind
  27432. * - VertexBuffer.MatricesWeightsKind
  27433. * - VertexBuffer.MatricesWeightsExtraKind
  27434. * @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
  27435. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27436. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27437. */
  27438. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27439. /**
  27440. * Returns the mesh VertexBuffer object from the requested `kind`
  27441. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27442. * - VertexBuffer.PositionKind
  27443. * - VertexBuffer.NormalKind
  27444. * - VertexBuffer.UVKind
  27445. * - VertexBuffer.UV2Kind
  27446. * - VertexBuffer.UV3Kind
  27447. * - VertexBuffer.UV4Kind
  27448. * - VertexBuffer.UV5Kind
  27449. * - VertexBuffer.UV6Kind
  27450. * - VertexBuffer.ColorKind
  27451. * - VertexBuffer.MatricesIndicesKind
  27452. * - VertexBuffer.MatricesIndicesExtraKind
  27453. * - VertexBuffer.MatricesWeightsKind
  27454. * - VertexBuffer.MatricesWeightsExtraKind
  27455. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27456. */
  27457. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27458. /**
  27459. * Tests if a specific vertex buffer is associated with this mesh
  27460. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27461. * - VertexBuffer.PositionKind
  27462. * - VertexBuffer.NormalKind
  27463. * - VertexBuffer.UVKind
  27464. * - VertexBuffer.UV2Kind
  27465. * - VertexBuffer.UV3Kind
  27466. * - VertexBuffer.UV4Kind
  27467. * - VertexBuffer.UV5Kind
  27468. * - VertexBuffer.UV6Kind
  27469. * - VertexBuffer.ColorKind
  27470. * - VertexBuffer.MatricesIndicesKind
  27471. * - VertexBuffer.MatricesIndicesExtraKind
  27472. * - VertexBuffer.MatricesWeightsKind
  27473. * - VertexBuffer.MatricesWeightsExtraKind
  27474. * @returns a boolean
  27475. */
  27476. isVerticesDataPresent(kind: string): boolean;
  27477. /**
  27478. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27479. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27480. * - VertexBuffer.PositionKind
  27481. * - VertexBuffer.UVKind
  27482. * - VertexBuffer.UV2Kind
  27483. * - VertexBuffer.UV3Kind
  27484. * - VertexBuffer.UV4Kind
  27485. * - VertexBuffer.UV5Kind
  27486. * - VertexBuffer.UV6Kind
  27487. * - VertexBuffer.ColorKind
  27488. * - VertexBuffer.MatricesIndicesKind
  27489. * - VertexBuffer.MatricesIndicesExtraKind
  27490. * - VertexBuffer.MatricesWeightsKind
  27491. * - VertexBuffer.MatricesWeightsExtraKind
  27492. * @returns a boolean
  27493. */
  27494. isVertexBufferUpdatable(kind: string): boolean;
  27495. /**
  27496. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27497. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27498. * - VertexBuffer.PositionKind
  27499. * - VertexBuffer.NormalKind
  27500. * - VertexBuffer.UVKind
  27501. * - VertexBuffer.UV2Kind
  27502. * - VertexBuffer.UV3Kind
  27503. * - VertexBuffer.UV4Kind
  27504. * - VertexBuffer.UV5Kind
  27505. * - VertexBuffer.UV6Kind
  27506. * - VertexBuffer.ColorKind
  27507. * - VertexBuffer.MatricesIndicesKind
  27508. * - VertexBuffer.MatricesIndicesExtraKind
  27509. * - VertexBuffer.MatricesWeightsKind
  27510. * - VertexBuffer.MatricesWeightsExtraKind
  27511. * @returns an array of strings
  27512. */
  27513. getVerticesDataKinds(): string[];
  27514. /**
  27515. * Returns a positive integer : the total number of indices in this mesh geometry.
  27516. * @returns the numner of indices or zero if the mesh has no geometry.
  27517. */
  27518. getTotalIndices(): number;
  27519. /**
  27520. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27521. * @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.
  27522. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27523. * @returns the indices array or an empty array if the mesh has no geometry
  27524. */
  27525. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27526. get isBlocked(): boolean;
  27527. /**
  27528. * Determine if the current mesh is ready to be rendered
  27529. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27530. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27531. * @returns true if all associated assets are ready (material, textures, shaders)
  27532. */
  27533. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27534. /**
  27535. * 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.
  27536. */
  27537. get areNormalsFrozen(): boolean;
  27538. /**
  27539. * 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.
  27540. * @returns the current mesh
  27541. */
  27542. freezeNormals(): Mesh;
  27543. /**
  27544. * 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
  27545. * @returns the current mesh
  27546. */
  27547. unfreezeNormals(): Mesh;
  27548. /**
  27549. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27550. */
  27551. set overridenInstanceCount(count: number);
  27552. /** @hidden */
  27553. _preActivate(): Mesh;
  27554. /** @hidden */
  27555. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27556. /** @hidden */
  27557. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27558. /**
  27559. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27560. * This means the mesh underlying bounding box and sphere are recomputed.
  27561. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27562. * @returns the current mesh
  27563. */
  27564. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27565. /** @hidden */
  27566. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27567. /**
  27568. * This function will subdivide the mesh into multiple submeshes
  27569. * @param count defines the expected number of submeshes
  27570. */
  27571. subdivide(count: number): void;
  27572. /**
  27573. * Copy a FloatArray into a specific associated vertex buffer
  27574. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27575. * - VertexBuffer.PositionKind
  27576. * - VertexBuffer.UVKind
  27577. * - VertexBuffer.UV2Kind
  27578. * - VertexBuffer.UV3Kind
  27579. * - VertexBuffer.UV4Kind
  27580. * - VertexBuffer.UV5Kind
  27581. * - VertexBuffer.UV6Kind
  27582. * - VertexBuffer.ColorKind
  27583. * - VertexBuffer.MatricesIndicesKind
  27584. * - VertexBuffer.MatricesIndicesExtraKind
  27585. * - VertexBuffer.MatricesWeightsKind
  27586. * - VertexBuffer.MatricesWeightsExtraKind
  27587. * @param data defines the data source
  27588. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27589. * @param stride defines the data stride size (can be null)
  27590. * @returns the current mesh
  27591. */
  27592. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27593. /**
  27594. * Delete a vertex buffer associated with this mesh
  27595. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27596. * - VertexBuffer.PositionKind
  27597. * - VertexBuffer.UVKind
  27598. * - VertexBuffer.UV2Kind
  27599. * - VertexBuffer.UV3Kind
  27600. * - VertexBuffer.UV4Kind
  27601. * - VertexBuffer.UV5Kind
  27602. * - VertexBuffer.UV6Kind
  27603. * - VertexBuffer.ColorKind
  27604. * - VertexBuffer.MatricesIndicesKind
  27605. * - VertexBuffer.MatricesIndicesExtraKind
  27606. * - VertexBuffer.MatricesWeightsKind
  27607. * - VertexBuffer.MatricesWeightsExtraKind
  27608. */
  27609. removeVerticesData(kind: string): void;
  27610. /**
  27611. * Flags an associated vertex buffer as updatable
  27612. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27613. * - VertexBuffer.PositionKind
  27614. * - VertexBuffer.UVKind
  27615. * - VertexBuffer.UV2Kind
  27616. * - VertexBuffer.UV3Kind
  27617. * - VertexBuffer.UV4Kind
  27618. * - VertexBuffer.UV5Kind
  27619. * - VertexBuffer.UV6Kind
  27620. * - VertexBuffer.ColorKind
  27621. * - VertexBuffer.MatricesIndicesKind
  27622. * - VertexBuffer.MatricesIndicesExtraKind
  27623. * - VertexBuffer.MatricesWeightsKind
  27624. * - VertexBuffer.MatricesWeightsExtraKind
  27625. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27626. */
  27627. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27628. /**
  27629. * Sets the mesh global Vertex Buffer
  27630. * @param buffer defines the buffer to use
  27631. * @returns the current mesh
  27632. */
  27633. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27634. /**
  27635. * Update a specific associated vertex buffer
  27636. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27637. * - VertexBuffer.PositionKind
  27638. * - VertexBuffer.UVKind
  27639. * - VertexBuffer.UV2Kind
  27640. * - VertexBuffer.UV3Kind
  27641. * - VertexBuffer.UV4Kind
  27642. * - VertexBuffer.UV5Kind
  27643. * - VertexBuffer.UV6Kind
  27644. * - VertexBuffer.ColorKind
  27645. * - VertexBuffer.MatricesIndicesKind
  27646. * - VertexBuffer.MatricesIndicesExtraKind
  27647. * - VertexBuffer.MatricesWeightsKind
  27648. * - VertexBuffer.MatricesWeightsExtraKind
  27649. * @param data defines the data source
  27650. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27651. * @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)
  27652. * @returns the current mesh
  27653. */
  27654. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27655. /**
  27656. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27657. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27658. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27659. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27660. * @returns the current mesh
  27661. */
  27662. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27663. /**
  27664. * Creates a un-shared specific occurence of the geometry for the mesh.
  27665. * @returns the current mesh
  27666. */
  27667. makeGeometryUnique(): Mesh;
  27668. /**
  27669. * Set the index buffer of this mesh
  27670. * @param indices defines the source data
  27671. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27672. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27673. * @returns the current mesh
  27674. */
  27675. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27676. /**
  27677. * Update the current index buffer
  27678. * @param indices defines the source data
  27679. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27680. * @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)
  27681. * @returns the current mesh
  27682. */
  27683. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27684. /**
  27685. * Invert the geometry to move from a right handed system to a left handed one.
  27686. * @returns the current mesh
  27687. */
  27688. toLeftHanded(): Mesh;
  27689. /** @hidden */
  27690. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27691. /** @hidden */
  27692. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27693. /**
  27694. * Registers for this mesh a javascript function called just before the rendering process
  27695. * @param func defines the function to call before rendering this mesh
  27696. * @returns the current mesh
  27697. */
  27698. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27699. /**
  27700. * Disposes a previously registered javascript function called before the rendering
  27701. * @param func defines the function to remove
  27702. * @returns the current mesh
  27703. */
  27704. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27705. /**
  27706. * Registers for this mesh a javascript function called just after the rendering is complete
  27707. * @param func defines the function to call after rendering this mesh
  27708. * @returns the current mesh
  27709. */
  27710. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27711. /**
  27712. * Disposes a previously registered javascript function called after the rendering.
  27713. * @param func defines the function to remove
  27714. * @returns the current mesh
  27715. */
  27716. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27717. /** @hidden */
  27718. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27719. /** @hidden */
  27720. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27721. /** @hidden */
  27722. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27723. /** @hidden */
  27724. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27725. /** @hidden */
  27726. _rebuild(): void;
  27727. /** @hidden */
  27728. _freeze(): void;
  27729. /** @hidden */
  27730. _unFreeze(): void;
  27731. /**
  27732. * 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
  27733. * @param subMesh defines the subMesh to render
  27734. * @param enableAlphaMode defines if alpha mode can be changed
  27735. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27736. * @returns the current mesh
  27737. */
  27738. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27739. private _onBeforeDraw;
  27740. /**
  27741. * Renormalize the mesh and patch it up if there are no weights
  27742. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27743. * However in the case of zero weights then we set just a single influence to 1.
  27744. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27745. */
  27746. cleanMatrixWeights(): void;
  27747. private normalizeSkinFourWeights;
  27748. private normalizeSkinWeightsAndExtra;
  27749. /**
  27750. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27751. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27752. * the user know there was an issue with importing the mesh
  27753. * @returns a validation object with skinned, valid and report string
  27754. */
  27755. validateSkinning(): {
  27756. skinned: boolean;
  27757. valid: boolean;
  27758. report: string;
  27759. };
  27760. /** @hidden */
  27761. _checkDelayState(): Mesh;
  27762. private _queueLoad;
  27763. /**
  27764. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27765. * A mesh is in the frustum if its bounding box intersects the frustum
  27766. * @param frustumPlanes defines the frustum to test
  27767. * @returns true if the mesh is in the frustum planes
  27768. */
  27769. isInFrustum(frustumPlanes: Plane[]): boolean;
  27770. /**
  27771. * Sets the mesh material by the material or multiMaterial `id` property
  27772. * @param id is a string identifying the material or the multiMaterial
  27773. * @returns the current mesh
  27774. */
  27775. setMaterialByID(id: string): Mesh;
  27776. /**
  27777. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27778. * @returns an array of IAnimatable
  27779. */
  27780. getAnimatables(): IAnimatable[];
  27781. /**
  27782. * Modifies the mesh geometry according to the passed transformation matrix.
  27783. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27784. * The mesh normals are modified using the same transformation.
  27785. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27786. * @param transform defines the transform matrix to use
  27787. * @see http://doc.babylonjs.com/resources/baking_transformations
  27788. * @returns the current mesh
  27789. */
  27790. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27791. /**
  27792. * Modifies the mesh geometry according to its own current World Matrix.
  27793. * The mesh World Matrix is then reset.
  27794. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27795. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27796. * @see http://doc.babylonjs.com/resources/baking_transformations
  27797. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27798. * @returns the current mesh
  27799. */
  27800. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27801. /** @hidden */
  27802. get _positions(): Nullable<Vector3[]>;
  27803. /** @hidden */
  27804. _resetPointsArrayCache(): Mesh;
  27805. /** @hidden */
  27806. _generatePointsArray(): boolean;
  27807. /**
  27808. * Returns a new Mesh object generated from the current mesh properties.
  27809. * This method must not get confused with createInstance()
  27810. * @param name is a string, the name given to the new mesh
  27811. * @param newParent can be any Node object (default `null`)
  27812. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27813. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27814. * @returns a new mesh
  27815. */
  27816. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27817. /**
  27818. * Releases resources associated with this mesh.
  27819. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27820. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27821. */
  27822. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27823. /** @hidden */
  27824. _disposeInstanceSpecificData(): void;
  27825. /**
  27826. * Modifies the mesh geometry according to a displacement map.
  27827. * 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.
  27828. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27829. * @param url is a string, the URL from the image file is to be downloaded.
  27830. * @param minHeight is the lower limit of the displacement.
  27831. * @param maxHeight is the upper limit of the displacement.
  27832. * @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.
  27833. * @param uvOffset is an optional vector2 used to offset UV.
  27834. * @param uvScale is an optional vector2 used to scale UV.
  27835. * @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.
  27836. * @returns the Mesh.
  27837. */
  27838. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27839. /**
  27840. * Modifies the mesh geometry according to a displacementMap buffer.
  27841. * 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.
  27842. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27843. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27844. * @param heightMapWidth is the width of the buffer image.
  27845. * @param heightMapHeight is the height of the buffer image.
  27846. * @param minHeight is the lower limit of the displacement.
  27847. * @param maxHeight is the upper limit of the displacement.
  27848. * @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.
  27849. * @param uvOffset is an optional vector2 used to offset UV.
  27850. * @param uvScale is an optional vector2 used to scale UV.
  27851. * @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.
  27852. * @returns the Mesh.
  27853. */
  27854. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27855. /**
  27856. * Modify the mesh to get a flat shading rendering.
  27857. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27858. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27859. * @returns current mesh
  27860. */
  27861. convertToFlatShadedMesh(): Mesh;
  27862. /**
  27863. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27864. * In other words, more vertices, no more indices and a single bigger VBO.
  27865. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27866. * @returns current mesh
  27867. */
  27868. convertToUnIndexedMesh(): Mesh;
  27869. /**
  27870. * Inverses facet orientations.
  27871. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27872. * @param flipNormals will also inverts the normals
  27873. * @returns current mesh
  27874. */
  27875. flipFaces(flipNormals?: boolean): Mesh;
  27876. /**
  27877. * Increase the number of facets and hence vertices in a mesh
  27878. * Vertex normals are interpolated from existing vertex normals
  27879. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27880. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27881. */
  27882. increaseVertices(numberPerEdge: number): void;
  27883. /**
  27884. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27885. * This will undo any application of covertToFlatShadedMesh
  27886. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27887. */
  27888. forceSharedVertices(): void;
  27889. /** @hidden */
  27890. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27891. /** @hidden */
  27892. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27893. /**
  27894. * Creates a new InstancedMesh object from the mesh model.
  27895. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27896. * @param name defines the name of the new instance
  27897. * @returns a new InstancedMesh
  27898. */
  27899. createInstance(name: string): InstancedMesh;
  27900. /**
  27901. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27902. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27903. * @returns the current mesh
  27904. */
  27905. synchronizeInstances(): Mesh;
  27906. /**
  27907. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27908. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27909. * This should be used together with the simplification to avoid disappearing triangles.
  27910. * @param successCallback an optional success callback to be called after the optimization finished.
  27911. * @returns the current mesh
  27912. */
  27913. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27914. /**
  27915. * Serialize current mesh
  27916. * @param serializationObject defines the object which will receive the serialization data
  27917. */
  27918. serialize(serializationObject: any): void;
  27919. /** @hidden */
  27920. _syncGeometryWithMorphTargetManager(): void;
  27921. /** @hidden */
  27922. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  27923. /**
  27924. * Returns a new Mesh object parsed from the source provided.
  27925. * @param parsedMesh is the source
  27926. * @param scene defines the hosting scene
  27927. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27928. * @returns a new Mesh
  27929. */
  27930. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27931. /**
  27932. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27933. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27934. * @param name defines the name of the mesh to create
  27935. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27936. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27937. * @param closePath creates a seam between the first and the last points of each path of the path array
  27938. * @param offset is taken in account only if the `pathArray` is containing a single path
  27939. * @param scene defines the hosting scene
  27940. * @param updatable defines if the mesh must be flagged as updatable
  27941. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27942. * @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)
  27943. * @returns a new Mesh
  27944. */
  27945. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27946. /**
  27947. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27948. * @param name defines the name of the mesh to create
  27949. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27950. * @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
  27951. * @param scene defines the hosting scene
  27952. * @param updatable defines if the mesh must be flagged as updatable
  27953. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27954. * @returns a new Mesh
  27955. */
  27956. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27957. /**
  27958. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27959. * @param name defines the name of the mesh to create
  27960. * @param size sets the size (float) of each box side (default 1)
  27961. * @param scene defines the hosting scene
  27962. * @param updatable defines if the mesh must be flagged as updatable
  27963. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27964. * @returns a new Mesh
  27965. */
  27966. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27967. /**
  27968. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27969. * @param name defines the name of the mesh to create
  27970. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27971. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27972. * @param scene defines the hosting scene
  27973. * @param updatable defines if the mesh must be flagged as updatable
  27974. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27975. * @returns a new Mesh
  27976. */
  27977. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27978. /**
  27979. * Creates a hemisphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27982. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27983. * @param scene defines the hosting scene
  27984. * @returns a new Mesh
  27985. */
  27986. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  27987. /**
  27988. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27989. * @param name defines the name of the mesh to create
  27990. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27991. * @param diameterTop set the top cap diameter (floats, default 1)
  27992. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27993. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27994. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27995. * @param scene defines the hosting scene
  27996. * @param updatable defines if the mesh must be flagged as updatable
  27997. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27998. * @returns a new Mesh
  27999. */
  28000. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28001. /**
  28002. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28003. * @param name defines the name of the mesh to create
  28004. * @param diameter sets the diameter size (float) of the torus (default 1)
  28005. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28006. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28007. * @param scene defines the hosting scene
  28008. * @param updatable defines if the mesh must be flagged as updatable
  28009. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28010. * @returns a new Mesh
  28011. */
  28012. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28013. /**
  28014. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28015. * @param name defines the name of the mesh to create
  28016. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28017. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28018. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28019. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28020. * @param p the number of windings on X axis (positive integers, default 2)
  28021. * @param q the number of windings on Y axis (positive integers, default 3)
  28022. * @param scene defines the hosting scene
  28023. * @param updatable defines if the mesh must be flagged as updatable
  28024. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28025. * @returns a new Mesh
  28026. */
  28027. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28028. /**
  28029. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28030. * @param name defines the name of the mesh to create
  28031. * @param points is an array successive Vector3
  28032. * @param scene defines the hosting scene
  28033. * @param updatable defines if the mesh must be flagged as updatable
  28034. * @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).
  28035. * @returns a new Mesh
  28036. */
  28037. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28038. /**
  28039. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28040. * @param name defines the name of the mesh to create
  28041. * @param points is an array successive Vector3
  28042. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28043. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28044. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28045. * @param scene defines the hosting scene
  28046. * @param updatable defines if the mesh must be flagged as updatable
  28047. * @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)
  28048. * @returns a new Mesh
  28049. */
  28050. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28051. /**
  28052. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28053. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28054. * 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.
  28055. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28056. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28057. * Remember you can only change the shape positions, not their number when updating a polygon.
  28058. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28059. * @param name defines the name of the mesh to create
  28060. * @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
  28061. * @param scene defines the hosting scene
  28062. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28063. * @param updatable defines if the mesh must be flagged as updatable
  28064. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28065. * @param earcutInjection can be used to inject your own earcut reference
  28066. * @returns a new Mesh
  28067. */
  28068. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28069. /**
  28070. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28071. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28072. * @param name defines the name of the mesh to create
  28073. * @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
  28074. * @param depth defines the height of extrusion
  28075. * @param scene defines the hosting scene
  28076. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28077. * @param updatable defines if the mesh must be flagged as updatable
  28078. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28079. * @param earcutInjection can be used to inject your own earcut reference
  28080. * @returns a new Mesh
  28081. */
  28082. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28083. /**
  28084. * Creates an extruded shape mesh.
  28085. * 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
  28086. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28087. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28088. * @param name defines the name of the mesh to create
  28089. * @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
  28090. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28091. * @param scale is the value to scale the shape
  28092. * @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
  28093. * @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
  28094. * @param scene defines the hosting scene
  28095. * @param updatable defines if the mesh must be flagged as updatable
  28096. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28097. * @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)
  28098. * @returns a new Mesh
  28099. */
  28100. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28101. /**
  28102. * Creates an custom extruded shape mesh.
  28103. * The custom extrusion is a parametric shape.
  28104. * It has no predefined shape. Its final shape will depend on the input parameters.
  28105. * Please consider using the same method from the MeshBuilder class instead
  28106. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28107. * @param name defines the name of the mesh to create
  28108. * @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
  28109. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28110. * @param scaleFunction is a custom Javascript function called on each path point
  28111. * @param rotationFunction is a custom Javascript function called on each path point
  28112. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28113. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28114. * @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
  28115. * @param scene defines the hosting scene
  28116. * @param updatable defines if the mesh must be flagged as updatable
  28117. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28118. * @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)
  28119. * @returns a new Mesh
  28120. */
  28121. 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;
  28122. /**
  28123. * Creates lathe mesh.
  28124. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28125. * Please consider using the same method from the MeshBuilder class instead
  28126. * @param name defines the name of the mesh to create
  28127. * @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
  28128. * @param radius is the radius value of the lathe
  28129. * @param tessellation is the side number of the lathe.
  28130. * @param scene defines the hosting scene
  28131. * @param updatable defines if the mesh must be flagged as updatable
  28132. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28133. * @returns a new Mesh
  28134. */
  28135. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28136. /**
  28137. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28138. * @param name defines the name of the mesh to create
  28139. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28140. * @param scene defines the hosting scene
  28141. * @param updatable defines if the mesh must be flagged as updatable
  28142. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28143. * @returns a new Mesh
  28144. */
  28145. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28146. /**
  28147. * Creates a ground mesh.
  28148. * Please consider using the same method from the MeshBuilder class instead
  28149. * @param name defines the name of the mesh to create
  28150. * @param width set the width of the ground
  28151. * @param height set the height of the ground
  28152. * @param subdivisions sets the number of subdivisions per side
  28153. * @param scene defines the hosting scene
  28154. * @param updatable defines if the mesh must be flagged as updatable
  28155. * @returns a new Mesh
  28156. */
  28157. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28158. /**
  28159. * Creates a tiled ground mesh.
  28160. * Please consider using the same method from the MeshBuilder class instead
  28161. * @param name defines the name of the mesh to create
  28162. * @param xmin set the ground minimum X coordinate
  28163. * @param zmin set the ground minimum Y coordinate
  28164. * @param xmax set the ground maximum X coordinate
  28165. * @param zmax set the ground maximum Z coordinate
  28166. * @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
  28167. * @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
  28168. * @param scene defines the hosting scene
  28169. * @param updatable defines if the mesh must be flagged as updatable
  28170. * @returns a new Mesh
  28171. */
  28172. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28173. w: number;
  28174. h: number;
  28175. }, precision: {
  28176. w: number;
  28177. h: number;
  28178. }, scene: Scene, updatable?: boolean): Mesh;
  28179. /**
  28180. * Creates a ground mesh from a height map.
  28181. * Please consider using the same method from the MeshBuilder class instead
  28182. * @see http://doc.babylonjs.com/babylon101/height_map
  28183. * @param name defines the name of the mesh to create
  28184. * @param url sets the URL of the height map image resource
  28185. * @param width set the ground width size
  28186. * @param height set the ground height size
  28187. * @param subdivisions sets the number of subdivision per side
  28188. * @param minHeight is the minimum altitude on the ground
  28189. * @param maxHeight is the maximum altitude on the ground
  28190. * @param scene defines the hosting scene
  28191. * @param updatable defines if the mesh must be flagged as updatable
  28192. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28193. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28194. * @returns a new Mesh
  28195. */
  28196. 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;
  28197. /**
  28198. * Creates a tube mesh.
  28199. * The tube is a parametric shape.
  28200. * It has no predefined shape. Its final shape will depend on the input parameters.
  28201. * Please consider using the same method from the MeshBuilder class instead
  28202. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28203. * @param name defines the name of the mesh to create
  28204. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28205. * @param radius sets the tube radius size
  28206. * @param tessellation is the number of sides on the tubular surface
  28207. * @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
  28208. * @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
  28209. * @param scene defines the hosting scene
  28210. * @param updatable defines if the mesh must be flagged as updatable
  28211. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28212. * @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)
  28213. * @returns a new Mesh
  28214. */
  28215. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28216. (i: number, distance: number): number;
  28217. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28218. /**
  28219. * Creates a polyhedron mesh.
  28220. * Please consider using the same method from the MeshBuilder class instead.
  28221. * * 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
  28222. * * The parameter `size` (positive float, default 1) sets the polygon size
  28223. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28224. * * 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`
  28225. * * 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
  28226. * * 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)`)
  28227. * * 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
  28228. * * 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
  28229. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28230. * * 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
  28231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28232. * @param name defines the name of the mesh to create
  28233. * @param options defines the options used to create the mesh
  28234. * @param scene defines the hosting scene
  28235. * @returns a new Mesh
  28236. */
  28237. static CreatePolyhedron(name: string, options: {
  28238. type?: number;
  28239. size?: number;
  28240. sizeX?: number;
  28241. sizeY?: number;
  28242. sizeZ?: number;
  28243. custom?: any;
  28244. faceUV?: Vector4[];
  28245. faceColors?: Color4[];
  28246. updatable?: boolean;
  28247. sideOrientation?: number;
  28248. }, scene: Scene): Mesh;
  28249. /**
  28250. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28251. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28252. * * 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`)
  28253. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28254. * * 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
  28255. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28256. * * 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
  28257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28258. * @param name defines the name of the mesh
  28259. * @param options defines the options used to create the mesh
  28260. * @param scene defines the hosting scene
  28261. * @returns a new Mesh
  28262. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28263. */
  28264. static CreateIcoSphere(name: string, options: {
  28265. radius?: number;
  28266. flat?: boolean;
  28267. subdivisions?: number;
  28268. sideOrientation?: number;
  28269. updatable?: boolean;
  28270. }, scene: Scene): Mesh;
  28271. /**
  28272. * Creates a decal mesh.
  28273. * Please consider using the same method from the MeshBuilder class instead.
  28274. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28275. * @param name defines the name of the mesh
  28276. * @param sourceMesh defines the mesh receiving the decal
  28277. * @param position sets the position of the decal in world coordinates
  28278. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28279. * @param size sets the decal scaling
  28280. * @param angle sets the angle to rotate the decal
  28281. * @returns a new Mesh
  28282. */
  28283. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28284. /**
  28285. * Prepare internal position array for software CPU skinning
  28286. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28287. */
  28288. setPositionsForCPUSkinning(): Float32Array;
  28289. /**
  28290. * Prepare internal normal array for software CPU skinning
  28291. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28292. */
  28293. setNormalsForCPUSkinning(): Float32Array;
  28294. /**
  28295. * Updates the vertex buffer by applying transformation from the bones
  28296. * @param skeleton defines the skeleton to apply to current mesh
  28297. * @returns the current mesh
  28298. */
  28299. applySkeleton(skeleton: Skeleton): Mesh;
  28300. /**
  28301. * 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
  28302. * @param meshes defines the list of meshes to scan
  28303. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28304. */
  28305. static MinMax(meshes: AbstractMesh[]): {
  28306. min: Vector3;
  28307. max: Vector3;
  28308. };
  28309. /**
  28310. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28311. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28312. * @returns a vector3
  28313. */
  28314. static Center(meshesOrMinMaxVector: {
  28315. min: Vector3;
  28316. max: Vector3;
  28317. } | AbstractMesh[]): Vector3;
  28318. /**
  28319. * Merge the array of meshes into a single mesh for performance reasons.
  28320. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28321. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28322. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28323. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28324. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28325. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28326. * @returns a new mesh
  28327. */
  28328. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28329. /** @hidden */
  28330. addInstance(instance: InstancedMesh): void;
  28331. /** @hidden */
  28332. removeInstance(instance: InstancedMesh): void;
  28333. }
  28334. }
  28335. declare module BABYLON {
  28336. /**
  28337. * This is the base class of all the camera used in the application.
  28338. * @see http://doc.babylonjs.com/features/cameras
  28339. */
  28340. export class Camera extends Node {
  28341. /** @hidden */
  28342. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28343. /**
  28344. * This is the default projection mode used by the cameras.
  28345. * It helps recreating a feeling of perspective and better appreciate depth.
  28346. * This is the best way to simulate real life cameras.
  28347. */
  28348. static readonly PERSPECTIVE_CAMERA: number;
  28349. /**
  28350. * This helps creating camera with an orthographic mode.
  28351. * 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.
  28352. */
  28353. static readonly ORTHOGRAPHIC_CAMERA: number;
  28354. /**
  28355. * This is the default FOV mode for perspective cameras.
  28356. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28357. */
  28358. static readonly FOVMODE_VERTICAL_FIXED: number;
  28359. /**
  28360. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28361. */
  28362. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28363. /**
  28364. * This specifies ther is no need for a camera rig.
  28365. * Basically only one eye is rendered corresponding to the camera.
  28366. */
  28367. static readonly RIG_MODE_NONE: number;
  28368. /**
  28369. * Simulates a camera Rig with one blue eye and one red eye.
  28370. * This can be use with 3d blue and red glasses.
  28371. */
  28372. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28373. /**
  28374. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28375. */
  28376. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28377. /**
  28378. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28379. */
  28380. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28381. /**
  28382. * Defines that both eyes of the camera will be rendered over under each other.
  28383. */
  28384. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28385. /**
  28386. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28387. */
  28388. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28389. /**
  28390. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28391. */
  28392. static readonly RIG_MODE_VR: number;
  28393. /**
  28394. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28395. */
  28396. static readonly RIG_MODE_WEBVR: number;
  28397. /**
  28398. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28399. */
  28400. static readonly RIG_MODE_CUSTOM: number;
  28401. /**
  28402. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28403. */
  28404. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28405. /**
  28406. * Define the input manager associated with the camera.
  28407. */
  28408. inputs: CameraInputsManager<Camera>;
  28409. /** @hidden */
  28410. _position: Vector3;
  28411. /**
  28412. * Define the current local position of the camera in the scene
  28413. */
  28414. get position(): Vector3;
  28415. set position(newPosition: Vector3);
  28416. /**
  28417. * The vector the camera should consider as up.
  28418. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28419. */
  28420. upVector: Vector3;
  28421. /**
  28422. * Define the current limit on the left side for an orthographic camera
  28423. * In scene unit
  28424. */
  28425. orthoLeft: Nullable<number>;
  28426. /**
  28427. * Define the current limit on the right side for an orthographic camera
  28428. * In scene unit
  28429. */
  28430. orthoRight: Nullable<number>;
  28431. /**
  28432. * Define the current limit on the bottom side for an orthographic camera
  28433. * In scene unit
  28434. */
  28435. orthoBottom: Nullable<number>;
  28436. /**
  28437. * Define the current limit on the top side for an orthographic camera
  28438. * In scene unit
  28439. */
  28440. orthoTop: Nullable<number>;
  28441. /**
  28442. * Field Of View is set in Radians. (default is 0.8)
  28443. */
  28444. fov: number;
  28445. /**
  28446. * Define the minimum distance the camera can see from.
  28447. * This is important to note that the depth buffer are not infinite and the closer it starts
  28448. * the more your scene might encounter depth fighting issue.
  28449. */
  28450. minZ: number;
  28451. /**
  28452. * Define the maximum distance the camera can see to.
  28453. * This is important to note that the depth buffer are not infinite and the further it end
  28454. * the more your scene might encounter depth fighting issue.
  28455. */
  28456. maxZ: number;
  28457. /**
  28458. * Define the default inertia of the camera.
  28459. * This helps giving a smooth feeling to the camera movement.
  28460. */
  28461. inertia: number;
  28462. /**
  28463. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28464. */
  28465. mode: number;
  28466. /**
  28467. * Define whether the camera is intermediate.
  28468. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28469. */
  28470. isIntermediate: boolean;
  28471. /**
  28472. * Define the viewport of the camera.
  28473. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28474. */
  28475. viewport: Viewport;
  28476. /**
  28477. * Restricts the camera to viewing objects with the same layerMask.
  28478. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28479. */
  28480. layerMask: number;
  28481. /**
  28482. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28483. */
  28484. fovMode: number;
  28485. /**
  28486. * Rig mode of the camera.
  28487. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28488. * This is normally controlled byt the camera themselves as internal use.
  28489. */
  28490. cameraRigMode: number;
  28491. /**
  28492. * Defines the distance between both "eyes" in case of a RIG
  28493. */
  28494. interaxialDistance: number;
  28495. /**
  28496. * Defines if stereoscopic rendering is done side by side or over under.
  28497. */
  28498. isStereoscopicSideBySide: boolean;
  28499. /**
  28500. * 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
  28501. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28502. * else in the scene. (Eg. security camera)
  28503. *
  28504. * 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)
  28505. */
  28506. customRenderTargets: RenderTargetTexture[];
  28507. /**
  28508. * When set, the camera will render to this render target instead of the default canvas
  28509. *
  28510. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28511. */
  28512. outputRenderTarget: Nullable<RenderTargetTexture>;
  28513. /**
  28514. * Observable triggered when the camera view matrix has changed.
  28515. */
  28516. onViewMatrixChangedObservable: Observable<Camera>;
  28517. /**
  28518. * Observable triggered when the camera Projection matrix has changed.
  28519. */
  28520. onProjectionMatrixChangedObservable: Observable<Camera>;
  28521. /**
  28522. * Observable triggered when the inputs have been processed.
  28523. */
  28524. onAfterCheckInputsObservable: Observable<Camera>;
  28525. /**
  28526. * Observable triggered when reset has been called and applied to the camera.
  28527. */
  28528. onRestoreStateObservable: Observable<Camera>;
  28529. /**
  28530. * Is this camera a part of a rig system?
  28531. */
  28532. isRigCamera: boolean;
  28533. /**
  28534. * If isRigCamera set to true this will be set with the parent camera.
  28535. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28536. */
  28537. rigParent?: Camera;
  28538. /** @hidden */
  28539. _cameraRigParams: any;
  28540. /** @hidden */
  28541. _rigCameras: Camera[];
  28542. /** @hidden */
  28543. _rigPostProcess: Nullable<PostProcess>;
  28544. protected _webvrViewMatrix: Matrix;
  28545. /** @hidden */
  28546. _skipRendering: boolean;
  28547. /** @hidden */
  28548. _projectionMatrix: Matrix;
  28549. /** @hidden */
  28550. _postProcesses: Nullable<PostProcess>[];
  28551. /** @hidden */
  28552. _activeMeshes: SmartArray<AbstractMesh>;
  28553. protected _globalPosition: Vector3;
  28554. /** @hidden */
  28555. _computedViewMatrix: Matrix;
  28556. private _doNotComputeProjectionMatrix;
  28557. private _transformMatrix;
  28558. private _frustumPlanes;
  28559. private _refreshFrustumPlanes;
  28560. private _storedFov;
  28561. private _stateStored;
  28562. /**
  28563. * Instantiates a new camera object.
  28564. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28565. * @see http://doc.babylonjs.com/features/cameras
  28566. * @param name Defines the name of the camera in the scene
  28567. * @param position Defines the position of the camera
  28568. * @param scene Defines the scene the camera belongs too
  28569. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28570. */
  28571. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28572. /**
  28573. * Store current camera state (fov, position, etc..)
  28574. * @returns the camera
  28575. */
  28576. storeState(): Camera;
  28577. /**
  28578. * Restores the camera state values if it has been stored. You must call storeState() first
  28579. */
  28580. protected _restoreStateValues(): boolean;
  28581. /**
  28582. * Restored camera state. You must call storeState() first.
  28583. * @returns true if restored and false otherwise
  28584. */
  28585. restoreState(): boolean;
  28586. /**
  28587. * Gets the class name of the camera.
  28588. * @returns the class name
  28589. */
  28590. getClassName(): string;
  28591. /** @hidden */
  28592. readonly _isCamera: boolean;
  28593. /**
  28594. * Gets a string representation of the camera useful for debug purpose.
  28595. * @param fullDetails Defines that a more verboe level of logging is required
  28596. * @returns the string representation
  28597. */
  28598. toString(fullDetails?: boolean): string;
  28599. /**
  28600. * Gets the current world space position of the camera.
  28601. */
  28602. get globalPosition(): Vector3;
  28603. /**
  28604. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28605. * @returns the active meshe list
  28606. */
  28607. getActiveMeshes(): SmartArray<AbstractMesh>;
  28608. /**
  28609. * Check whether a mesh is part of the current active mesh list of the camera
  28610. * @param mesh Defines the mesh to check
  28611. * @returns true if active, false otherwise
  28612. */
  28613. isActiveMesh(mesh: Mesh): boolean;
  28614. /**
  28615. * Is this camera ready to be used/rendered
  28616. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28617. * @return true if the camera is ready
  28618. */
  28619. isReady(completeCheck?: boolean): boolean;
  28620. /** @hidden */
  28621. _initCache(): void;
  28622. /** @hidden */
  28623. _updateCache(ignoreParentClass?: boolean): void;
  28624. /** @hidden */
  28625. _isSynchronized(): boolean;
  28626. /** @hidden */
  28627. _isSynchronizedViewMatrix(): boolean;
  28628. /** @hidden */
  28629. _isSynchronizedProjectionMatrix(): boolean;
  28630. /**
  28631. * Attach the input controls to a specific dom element to get the input from.
  28632. * @param element Defines the element the controls should be listened from
  28633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28634. */
  28635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28636. /**
  28637. * Detach the current controls from the specified dom element.
  28638. * @param element Defines the element to stop listening the inputs from
  28639. */
  28640. detachControl(element: HTMLElement): void;
  28641. /**
  28642. * Update the camera state according to the different inputs gathered during the frame.
  28643. */
  28644. update(): void;
  28645. /** @hidden */
  28646. _checkInputs(): void;
  28647. /** @hidden */
  28648. get rigCameras(): Camera[];
  28649. /**
  28650. * Gets the post process used by the rig cameras
  28651. */
  28652. get rigPostProcess(): Nullable<PostProcess>;
  28653. /**
  28654. * Internal, gets the first post proces.
  28655. * @returns the first post process to be run on this camera.
  28656. */
  28657. _getFirstPostProcess(): Nullable<PostProcess>;
  28658. private _cascadePostProcessesToRigCams;
  28659. /**
  28660. * Attach a post process to the camera.
  28661. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28662. * @param postProcess The post process to attach to the camera
  28663. * @param insertAt The position of the post process in case several of them are in use in the scene
  28664. * @returns the position the post process has been inserted at
  28665. */
  28666. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28667. /**
  28668. * Detach a post process to the camera.
  28669. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28670. * @param postProcess The post process to detach from the camera
  28671. */
  28672. detachPostProcess(postProcess: PostProcess): void;
  28673. /**
  28674. * Gets the current world matrix of the camera
  28675. */
  28676. getWorldMatrix(): Matrix;
  28677. /** @hidden */
  28678. _getViewMatrix(): Matrix;
  28679. /**
  28680. * Gets the current view matrix of the camera.
  28681. * @param force forces the camera to recompute the matrix without looking at the cached state
  28682. * @returns the view matrix
  28683. */
  28684. getViewMatrix(force?: boolean): Matrix;
  28685. /**
  28686. * Freeze the projection matrix.
  28687. * It will prevent the cache check of the camera projection compute and can speed up perf
  28688. * if no parameter of the camera are meant to change
  28689. * @param projection Defines manually a projection if necessary
  28690. */
  28691. freezeProjectionMatrix(projection?: Matrix): void;
  28692. /**
  28693. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28694. */
  28695. unfreezeProjectionMatrix(): void;
  28696. /**
  28697. * Gets the current projection matrix of the camera.
  28698. * @param force forces the camera to recompute the matrix without looking at the cached state
  28699. * @returns the projection matrix
  28700. */
  28701. getProjectionMatrix(force?: boolean): Matrix;
  28702. /**
  28703. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28704. * @returns a Matrix
  28705. */
  28706. getTransformationMatrix(): Matrix;
  28707. private _updateFrustumPlanes;
  28708. /**
  28709. * Checks if a cullable object (mesh...) is in the camera frustum
  28710. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28711. * @param target The object to check
  28712. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28713. * @returns true if the object is in frustum otherwise false
  28714. */
  28715. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28716. /**
  28717. * Checks if a cullable object (mesh...) is in the camera frustum
  28718. * Unlike isInFrustum this cheks the full bounding box
  28719. * @param target The object to check
  28720. * @returns true if the object is in frustum otherwise false
  28721. */
  28722. isCompletelyInFrustum(target: ICullable): boolean;
  28723. /**
  28724. * Gets a ray in the forward direction from the camera.
  28725. * @param length Defines the length of the ray to create
  28726. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28727. * @param origin Defines the start point of the ray which defaults to the camera position
  28728. * @returns the forward ray
  28729. */
  28730. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28731. /**
  28732. * Releases resources associated with this node.
  28733. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28734. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28735. */
  28736. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28737. /** @hidden */
  28738. _isLeftCamera: boolean;
  28739. /**
  28740. * Gets the left camera of a rig setup in case of Rigged Camera
  28741. */
  28742. get isLeftCamera(): boolean;
  28743. /** @hidden */
  28744. _isRightCamera: boolean;
  28745. /**
  28746. * Gets the right camera of a rig setup in case of Rigged Camera
  28747. */
  28748. get isRightCamera(): boolean;
  28749. /**
  28750. * Gets the left camera of a rig setup in case of Rigged Camera
  28751. */
  28752. get leftCamera(): Nullable<FreeCamera>;
  28753. /**
  28754. * Gets the right camera of a rig setup in case of Rigged Camera
  28755. */
  28756. get rightCamera(): Nullable<FreeCamera>;
  28757. /**
  28758. * Gets the left camera target of a rig setup in case of Rigged Camera
  28759. * @returns the target position
  28760. */
  28761. getLeftTarget(): Nullable<Vector3>;
  28762. /**
  28763. * Gets the right camera target of a rig setup in case of Rigged Camera
  28764. * @returns the target position
  28765. */
  28766. getRightTarget(): Nullable<Vector3>;
  28767. /**
  28768. * @hidden
  28769. */
  28770. setCameraRigMode(mode: number, rigParams: any): void;
  28771. /** @hidden */
  28772. static _setStereoscopicRigMode(camera: Camera): void;
  28773. /** @hidden */
  28774. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28775. /** @hidden */
  28776. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28777. /** @hidden */
  28778. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28779. /** @hidden */
  28780. _getVRProjectionMatrix(): Matrix;
  28781. protected _updateCameraRotationMatrix(): void;
  28782. protected _updateWebVRCameraRotationMatrix(): void;
  28783. /**
  28784. * This function MUST be overwritten by the different WebVR cameras available.
  28785. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28786. * @hidden
  28787. */
  28788. _getWebVRProjectionMatrix(): Matrix;
  28789. /**
  28790. * This function MUST be overwritten by the different WebVR cameras available.
  28791. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28792. * @hidden
  28793. */
  28794. _getWebVRViewMatrix(): Matrix;
  28795. /** @hidden */
  28796. setCameraRigParameter(name: string, value: any): void;
  28797. /**
  28798. * needs to be overridden by children so sub has required properties to be copied
  28799. * @hidden
  28800. */
  28801. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28802. /**
  28803. * May need to be overridden by children
  28804. * @hidden
  28805. */
  28806. _updateRigCameras(): void;
  28807. /** @hidden */
  28808. _setupInputs(): void;
  28809. /**
  28810. * Serialiaze the camera setup to a json represention
  28811. * @returns the JSON representation
  28812. */
  28813. serialize(): any;
  28814. /**
  28815. * Clones the current camera.
  28816. * @param name The cloned camera name
  28817. * @returns the cloned camera
  28818. */
  28819. clone(name: string): Camera;
  28820. /**
  28821. * Gets the direction of the camera relative to a given local axis.
  28822. * @param localAxis Defines the reference axis to provide a relative direction.
  28823. * @return the direction
  28824. */
  28825. getDirection(localAxis: Vector3): Vector3;
  28826. /**
  28827. * Returns the current camera absolute rotation
  28828. */
  28829. get absoluteRotation(): Quaternion;
  28830. /**
  28831. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28832. * @param localAxis Defines the reference axis to provide a relative direction.
  28833. * @param result Defines the vector to store the result in
  28834. */
  28835. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28836. /**
  28837. * Gets a camera constructor for a given camera type
  28838. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28839. * @param name The name of the camera the result will be able to instantiate
  28840. * @param scene The scene the result will construct the camera in
  28841. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28842. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28843. * @returns a factory method to construc the camera
  28844. */
  28845. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28846. /**
  28847. * Compute the world matrix of the camera.
  28848. * @returns the camera world matrix
  28849. */
  28850. computeWorldMatrix(): Matrix;
  28851. /**
  28852. * Parse a JSON and creates the camera from the parsed information
  28853. * @param parsedCamera The JSON to parse
  28854. * @param scene The scene to instantiate the camera in
  28855. * @returns the newly constructed camera
  28856. */
  28857. static Parse(parsedCamera: any, scene: Scene): Camera;
  28858. }
  28859. }
  28860. declare module BABYLON {
  28861. /**
  28862. * Class containing static functions to help procedurally build meshes
  28863. */
  28864. export class DiscBuilder {
  28865. /**
  28866. * Creates a plane polygonal mesh. By default, this is a disc
  28867. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28868. * * 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
  28869. * * 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
  28870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28871. * * 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
  28872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28873. * @param name defines the name of the mesh
  28874. * @param options defines the options used to create the mesh
  28875. * @param scene defines the hosting scene
  28876. * @returns the plane polygonal mesh
  28877. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28878. */
  28879. static CreateDisc(name: string, options: {
  28880. radius?: number;
  28881. tessellation?: number;
  28882. arc?: number;
  28883. updatable?: boolean;
  28884. sideOrientation?: number;
  28885. frontUVs?: Vector4;
  28886. backUVs?: Vector4;
  28887. }, scene?: Nullable<Scene>): Mesh;
  28888. }
  28889. }
  28890. declare module BABYLON {
  28891. /**
  28892. * Options to be used when creating a FresnelParameters.
  28893. */
  28894. export type IFresnelParametersCreationOptions = {
  28895. /**
  28896. * Define the color used on edges (grazing angle)
  28897. */
  28898. leftColor?: Color3;
  28899. /**
  28900. * Define the color used on center
  28901. */
  28902. rightColor?: Color3;
  28903. /**
  28904. * Define bias applied to computed fresnel term
  28905. */
  28906. bias?: number;
  28907. /**
  28908. * Defined the power exponent applied to fresnel term
  28909. */
  28910. power?: number;
  28911. /**
  28912. * Define if the fresnel effect is enable or not.
  28913. */
  28914. isEnabled?: boolean;
  28915. };
  28916. /**
  28917. * Serialized format for FresnelParameters.
  28918. */
  28919. export type IFresnelParametersSerialized = {
  28920. /**
  28921. * Define the color used on edges (grazing angle) [as an array]
  28922. */
  28923. leftColor: number[];
  28924. /**
  28925. * Define the color used on center [as an array]
  28926. */
  28927. rightColor: number[];
  28928. /**
  28929. * Define bias applied to computed fresnel term
  28930. */
  28931. bias: number;
  28932. /**
  28933. * Defined the power exponent applied to fresnel term
  28934. */
  28935. power?: number;
  28936. /**
  28937. * Define if the fresnel effect is enable or not.
  28938. */
  28939. isEnabled: boolean;
  28940. };
  28941. /**
  28942. * This represents all the required information to add a fresnel effect on a material:
  28943. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28944. */
  28945. export class FresnelParameters {
  28946. private _isEnabled;
  28947. /**
  28948. * Define if the fresnel effect is enable or not.
  28949. */
  28950. get isEnabled(): boolean;
  28951. set isEnabled(value: boolean);
  28952. /**
  28953. * Define the color used on edges (grazing angle)
  28954. */
  28955. leftColor: Color3;
  28956. /**
  28957. * Define the color used on center
  28958. */
  28959. rightColor: Color3;
  28960. /**
  28961. * Define bias applied to computed fresnel term
  28962. */
  28963. bias: number;
  28964. /**
  28965. * Defined the power exponent applied to fresnel term
  28966. */
  28967. power: number;
  28968. /**
  28969. * Creates a new FresnelParameters object.
  28970. *
  28971. * @param options provide your own settings to optionally to override defaults
  28972. */
  28973. constructor(options?: IFresnelParametersCreationOptions);
  28974. /**
  28975. * Clones the current fresnel and its valuues
  28976. * @returns a clone fresnel configuration
  28977. */
  28978. clone(): FresnelParameters;
  28979. /**
  28980. * Determines equality between FresnelParameters objects
  28981. * @param otherFresnelParameters defines the second operand
  28982. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  28983. */
  28984. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  28985. /**
  28986. * Serializes the current fresnel parameters to a JSON representation.
  28987. * @return the JSON serialization
  28988. */
  28989. serialize(): IFresnelParametersSerialized;
  28990. /**
  28991. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28992. * @param parsedFresnelParameters Define the JSON representation
  28993. * @returns the parsed parameters
  28994. */
  28995. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  28996. }
  28997. }
  28998. declare module BABYLON {
  28999. /**
  29000. * This groups all the flags used to control the materials channel.
  29001. */
  29002. export class MaterialFlags {
  29003. private static _DiffuseTextureEnabled;
  29004. /**
  29005. * Are diffuse textures enabled in the application.
  29006. */
  29007. static get DiffuseTextureEnabled(): boolean;
  29008. static set DiffuseTextureEnabled(value: boolean);
  29009. private static _AmbientTextureEnabled;
  29010. /**
  29011. * Are ambient textures enabled in the application.
  29012. */
  29013. static get AmbientTextureEnabled(): boolean;
  29014. static set AmbientTextureEnabled(value: boolean);
  29015. private static _OpacityTextureEnabled;
  29016. /**
  29017. * Are opacity textures enabled in the application.
  29018. */
  29019. static get OpacityTextureEnabled(): boolean;
  29020. static set OpacityTextureEnabled(value: boolean);
  29021. private static _ReflectionTextureEnabled;
  29022. /**
  29023. * Are reflection textures enabled in the application.
  29024. */
  29025. static get ReflectionTextureEnabled(): boolean;
  29026. static set ReflectionTextureEnabled(value: boolean);
  29027. private static _EmissiveTextureEnabled;
  29028. /**
  29029. * Are emissive textures enabled in the application.
  29030. */
  29031. static get EmissiveTextureEnabled(): boolean;
  29032. static set EmissiveTextureEnabled(value: boolean);
  29033. private static _SpecularTextureEnabled;
  29034. /**
  29035. * Are specular textures enabled in the application.
  29036. */
  29037. static get SpecularTextureEnabled(): boolean;
  29038. static set SpecularTextureEnabled(value: boolean);
  29039. private static _BumpTextureEnabled;
  29040. /**
  29041. * Are bump textures enabled in the application.
  29042. */
  29043. static get BumpTextureEnabled(): boolean;
  29044. static set BumpTextureEnabled(value: boolean);
  29045. private static _LightmapTextureEnabled;
  29046. /**
  29047. * Are lightmap textures enabled in the application.
  29048. */
  29049. static get LightmapTextureEnabled(): boolean;
  29050. static set LightmapTextureEnabled(value: boolean);
  29051. private static _RefractionTextureEnabled;
  29052. /**
  29053. * Are refraction textures enabled in the application.
  29054. */
  29055. static get RefractionTextureEnabled(): boolean;
  29056. static set RefractionTextureEnabled(value: boolean);
  29057. private static _ColorGradingTextureEnabled;
  29058. /**
  29059. * Are color grading textures enabled in the application.
  29060. */
  29061. static get ColorGradingTextureEnabled(): boolean;
  29062. static set ColorGradingTextureEnabled(value: boolean);
  29063. private static _FresnelEnabled;
  29064. /**
  29065. * Are fresnels enabled in the application.
  29066. */
  29067. static get FresnelEnabled(): boolean;
  29068. static set FresnelEnabled(value: boolean);
  29069. private static _ClearCoatTextureEnabled;
  29070. /**
  29071. * Are clear coat textures enabled in the application.
  29072. */
  29073. static get ClearCoatTextureEnabled(): boolean;
  29074. static set ClearCoatTextureEnabled(value: boolean);
  29075. private static _ClearCoatBumpTextureEnabled;
  29076. /**
  29077. * Are clear coat bump textures enabled in the application.
  29078. */
  29079. static get ClearCoatBumpTextureEnabled(): boolean;
  29080. static set ClearCoatBumpTextureEnabled(value: boolean);
  29081. private static _ClearCoatTintTextureEnabled;
  29082. /**
  29083. * Are clear coat tint textures enabled in the application.
  29084. */
  29085. static get ClearCoatTintTextureEnabled(): boolean;
  29086. static set ClearCoatTintTextureEnabled(value: boolean);
  29087. private static _SheenTextureEnabled;
  29088. /**
  29089. * Are sheen textures enabled in the application.
  29090. */
  29091. static get SheenTextureEnabled(): boolean;
  29092. static set SheenTextureEnabled(value: boolean);
  29093. private static _AnisotropicTextureEnabled;
  29094. /**
  29095. * Are anisotropic textures enabled in the application.
  29096. */
  29097. static get AnisotropicTextureEnabled(): boolean;
  29098. static set AnisotropicTextureEnabled(value: boolean);
  29099. private static _ThicknessTextureEnabled;
  29100. /**
  29101. * Are thickness textures enabled in the application.
  29102. */
  29103. static get ThicknessTextureEnabled(): boolean;
  29104. static set ThicknessTextureEnabled(value: boolean);
  29105. }
  29106. }
  29107. declare module BABYLON {
  29108. /** @hidden */
  29109. export var defaultFragmentDeclaration: {
  29110. name: string;
  29111. shader: string;
  29112. };
  29113. }
  29114. declare module BABYLON {
  29115. /** @hidden */
  29116. export var defaultUboDeclaration: {
  29117. name: string;
  29118. shader: string;
  29119. };
  29120. }
  29121. declare module BABYLON {
  29122. /** @hidden */
  29123. export var lightFragmentDeclaration: {
  29124. name: string;
  29125. shader: string;
  29126. };
  29127. }
  29128. declare module BABYLON {
  29129. /** @hidden */
  29130. export var lightUboDeclaration: {
  29131. name: string;
  29132. shader: string;
  29133. };
  29134. }
  29135. declare module BABYLON {
  29136. /** @hidden */
  29137. export var lightsFragmentFunctions: {
  29138. name: string;
  29139. shader: string;
  29140. };
  29141. }
  29142. declare module BABYLON {
  29143. /** @hidden */
  29144. export var shadowsFragmentFunctions: {
  29145. name: string;
  29146. shader: string;
  29147. };
  29148. }
  29149. declare module BABYLON {
  29150. /** @hidden */
  29151. export var fresnelFunction: {
  29152. name: string;
  29153. shader: string;
  29154. };
  29155. }
  29156. declare module BABYLON {
  29157. /** @hidden */
  29158. export var bumpFragmentMainFunctions: {
  29159. name: string;
  29160. shader: string;
  29161. };
  29162. }
  29163. declare module BABYLON {
  29164. /** @hidden */
  29165. export var bumpFragmentFunctions: {
  29166. name: string;
  29167. shader: string;
  29168. };
  29169. }
  29170. declare module BABYLON {
  29171. /** @hidden */
  29172. export var logDepthDeclaration: {
  29173. name: string;
  29174. shader: string;
  29175. };
  29176. }
  29177. declare module BABYLON {
  29178. /** @hidden */
  29179. export var bumpFragment: {
  29180. name: string;
  29181. shader: string;
  29182. };
  29183. }
  29184. declare module BABYLON {
  29185. /** @hidden */
  29186. export var depthPrePass: {
  29187. name: string;
  29188. shader: string;
  29189. };
  29190. }
  29191. declare module BABYLON {
  29192. /** @hidden */
  29193. export var lightFragment: {
  29194. name: string;
  29195. shader: string;
  29196. };
  29197. }
  29198. declare module BABYLON {
  29199. /** @hidden */
  29200. export var logDepthFragment: {
  29201. name: string;
  29202. shader: string;
  29203. };
  29204. }
  29205. declare module BABYLON {
  29206. /** @hidden */
  29207. export var defaultPixelShader: {
  29208. name: string;
  29209. shader: string;
  29210. };
  29211. }
  29212. declare module BABYLON {
  29213. /** @hidden */
  29214. export var defaultVertexDeclaration: {
  29215. name: string;
  29216. shader: string;
  29217. };
  29218. }
  29219. declare module BABYLON {
  29220. /** @hidden */
  29221. export var bumpVertexDeclaration: {
  29222. name: string;
  29223. shader: string;
  29224. };
  29225. }
  29226. declare module BABYLON {
  29227. /** @hidden */
  29228. export var bumpVertex: {
  29229. name: string;
  29230. shader: string;
  29231. };
  29232. }
  29233. declare module BABYLON {
  29234. /** @hidden */
  29235. export var fogVertex: {
  29236. name: string;
  29237. shader: string;
  29238. };
  29239. }
  29240. declare module BABYLON {
  29241. /** @hidden */
  29242. export var shadowsVertex: {
  29243. name: string;
  29244. shader: string;
  29245. };
  29246. }
  29247. declare module BABYLON {
  29248. /** @hidden */
  29249. export var pointCloudVertex: {
  29250. name: string;
  29251. shader: string;
  29252. };
  29253. }
  29254. declare module BABYLON {
  29255. /** @hidden */
  29256. export var logDepthVertex: {
  29257. name: string;
  29258. shader: string;
  29259. };
  29260. }
  29261. declare module BABYLON {
  29262. /** @hidden */
  29263. export var defaultVertexShader: {
  29264. name: string;
  29265. shader: string;
  29266. };
  29267. }
  29268. declare module BABYLON {
  29269. /** @hidden */
  29270. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29271. MAINUV1: boolean;
  29272. MAINUV2: boolean;
  29273. DIFFUSE: boolean;
  29274. DIFFUSEDIRECTUV: number;
  29275. AMBIENT: boolean;
  29276. AMBIENTDIRECTUV: number;
  29277. OPACITY: boolean;
  29278. OPACITYDIRECTUV: number;
  29279. OPACITYRGB: boolean;
  29280. REFLECTION: boolean;
  29281. EMISSIVE: boolean;
  29282. EMISSIVEDIRECTUV: number;
  29283. SPECULAR: boolean;
  29284. SPECULARDIRECTUV: number;
  29285. BUMP: boolean;
  29286. BUMPDIRECTUV: number;
  29287. PARALLAX: boolean;
  29288. PARALLAXOCCLUSION: boolean;
  29289. SPECULAROVERALPHA: boolean;
  29290. CLIPPLANE: boolean;
  29291. CLIPPLANE2: boolean;
  29292. CLIPPLANE3: boolean;
  29293. CLIPPLANE4: boolean;
  29294. CLIPPLANE5: boolean;
  29295. CLIPPLANE6: boolean;
  29296. ALPHATEST: boolean;
  29297. DEPTHPREPASS: boolean;
  29298. ALPHAFROMDIFFUSE: boolean;
  29299. POINTSIZE: boolean;
  29300. FOG: boolean;
  29301. SPECULARTERM: boolean;
  29302. DIFFUSEFRESNEL: boolean;
  29303. OPACITYFRESNEL: boolean;
  29304. REFLECTIONFRESNEL: boolean;
  29305. REFRACTIONFRESNEL: boolean;
  29306. EMISSIVEFRESNEL: boolean;
  29307. FRESNEL: boolean;
  29308. NORMAL: boolean;
  29309. UV1: boolean;
  29310. UV2: boolean;
  29311. VERTEXCOLOR: boolean;
  29312. VERTEXALPHA: boolean;
  29313. NUM_BONE_INFLUENCERS: number;
  29314. BonesPerMesh: number;
  29315. BONETEXTURE: boolean;
  29316. INSTANCES: boolean;
  29317. GLOSSINESS: boolean;
  29318. ROUGHNESS: boolean;
  29319. EMISSIVEASILLUMINATION: boolean;
  29320. LINKEMISSIVEWITHDIFFUSE: boolean;
  29321. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29322. LIGHTMAP: boolean;
  29323. LIGHTMAPDIRECTUV: number;
  29324. OBJECTSPACE_NORMALMAP: boolean;
  29325. USELIGHTMAPASSHADOWMAP: boolean;
  29326. REFLECTIONMAP_3D: boolean;
  29327. REFLECTIONMAP_SPHERICAL: boolean;
  29328. REFLECTIONMAP_PLANAR: boolean;
  29329. REFLECTIONMAP_CUBIC: boolean;
  29330. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29331. REFLECTIONMAP_PROJECTION: boolean;
  29332. REFLECTIONMAP_SKYBOX: boolean;
  29333. REFLECTIONMAP_EXPLICIT: boolean;
  29334. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29335. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29336. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29337. INVERTCUBICMAP: boolean;
  29338. LOGARITHMICDEPTH: boolean;
  29339. REFRACTION: boolean;
  29340. REFRACTIONMAP_3D: boolean;
  29341. REFLECTIONOVERALPHA: boolean;
  29342. TWOSIDEDLIGHTING: boolean;
  29343. SHADOWFLOAT: boolean;
  29344. MORPHTARGETS: boolean;
  29345. MORPHTARGETS_NORMAL: boolean;
  29346. MORPHTARGETS_TANGENT: boolean;
  29347. MORPHTARGETS_UV: boolean;
  29348. NUM_MORPH_INFLUENCERS: number;
  29349. NONUNIFORMSCALING: boolean;
  29350. PREMULTIPLYALPHA: boolean;
  29351. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29352. ALPHABLEND: boolean;
  29353. RGBDLIGHTMAP: boolean;
  29354. RGBDREFLECTION: boolean;
  29355. RGBDREFRACTION: boolean;
  29356. IMAGEPROCESSING: boolean;
  29357. VIGNETTE: boolean;
  29358. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29359. VIGNETTEBLENDMODEOPAQUE: boolean;
  29360. TONEMAPPING: boolean;
  29361. TONEMAPPING_ACES: boolean;
  29362. CONTRAST: boolean;
  29363. COLORCURVES: boolean;
  29364. COLORGRADING: boolean;
  29365. COLORGRADING3D: boolean;
  29366. SAMPLER3DGREENDEPTH: boolean;
  29367. SAMPLER3DBGRMAP: boolean;
  29368. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29369. MULTIVIEW: boolean;
  29370. /**
  29371. * If the reflection texture on this material is in linear color space
  29372. * @hidden
  29373. */
  29374. IS_REFLECTION_LINEAR: boolean;
  29375. /**
  29376. * If the refraction texture on this material is in linear color space
  29377. * @hidden
  29378. */
  29379. IS_REFRACTION_LINEAR: boolean;
  29380. EXPOSURE: boolean;
  29381. constructor();
  29382. setReflectionMode(modeToEnable: string): void;
  29383. }
  29384. /**
  29385. * This is the default material used in Babylon. It is the best trade off between quality
  29386. * and performances.
  29387. * @see http://doc.babylonjs.com/babylon101/materials
  29388. */
  29389. export class StandardMaterial extends PushMaterial {
  29390. private _diffuseTexture;
  29391. /**
  29392. * The basic texture of the material as viewed under a light.
  29393. */
  29394. diffuseTexture: Nullable<BaseTexture>;
  29395. private _ambientTexture;
  29396. /**
  29397. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29398. */
  29399. ambientTexture: Nullable<BaseTexture>;
  29400. private _opacityTexture;
  29401. /**
  29402. * Define the transparency of the material from a texture.
  29403. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29404. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29405. */
  29406. opacityTexture: Nullable<BaseTexture>;
  29407. private _reflectionTexture;
  29408. /**
  29409. * Define the texture used to display the reflection.
  29410. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29411. */
  29412. reflectionTexture: Nullable<BaseTexture>;
  29413. private _emissiveTexture;
  29414. /**
  29415. * Define texture of the material as if self lit.
  29416. * This will be mixed in the final result even in the absence of light.
  29417. */
  29418. emissiveTexture: Nullable<BaseTexture>;
  29419. private _specularTexture;
  29420. /**
  29421. * Define how the color and intensity of the highlight given by the light in the material.
  29422. */
  29423. specularTexture: Nullable<BaseTexture>;
  29424. private _bumpTexture;
  29425. /**
  29426. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29427. * 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.
  29428. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29429. */
  29430. bumpTexture: Nullable<BaseTexture>;
  29431. private _lightmapTexture;
  29432. /**
  29433. * Complex lighting can be computationally expensive to compute at runtime.
  29434. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29435. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29436. */
  29437. lightmapTexture: Nullable<BaseTexture>;
  29438. private _refractionTexture;
  29439. /**
  29440. * Define the texture used to display the refraction.
  29441. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29442. */
  29443. refractionTexture: Nullable<BaseTexture>;
  29444. /**
  29445. * The color of the material lit by the environmental background lighting.
  29446. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29447. */
  29448. ambientColor: Color3;
  29449. /**
  29450. * The basic color of the material as viewed under a light.
  29451. */
  29452. diffuseColor: Color3;
  29453. /**
  29454. * Define how the color and intensity of the highlight given by the light in the material.
  29455. */
  29456. specularColor: Color3;
  29457. /**
  29458. * Define the color of the material as if self lit.
  29459. * This will be mixed in the final result even in the absence of light.
  29460. */
  29461. emissiveColor: Color3;
  29462. /**
  29463. * Defines how sharp are the highlights in the material.
  29464. * The bigger the value the sharper giving a more glossy feeling to the result.
  29465. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29466. */
  29467. specularPower: number;
  29468. private _useAlphaFromDiffuseTexture;
  29469. /**
  29470. * Does the transparency come from the diffuse texture alpha channel.
  29471. */
  29472. useAlphaFromDiffuseTexture: boolean;
  29473. private _useEmissiveAsIllumination;
  29474. /**
  29475. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29476. */
  29477. useEmissiveAsIllumination: boolean;
  29478. private _linkEmissiveWithDiffuse;
  29479. /**
  29480. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29481. * the emissive level when the final color is close to one.
  29482. */
  29483. linkEmissiveWithDiffuse: boolean;
  29484. private _useSpecularOverAlpha;
  29485. /**
  29486. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29487. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29488. */
  29489. useSpecularOverAlpha: boolean;
  29490. private _useReflectionOverAlpha;
  29491. /**
  29492. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29493. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29494. */
  29495. useReflectionOverAlpha: boolean;
  29496. private _disableLighting;
  29497. /**
  29498. * Does lights from the scene impacts this material.
  29499. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29500. */
  29501. disableLighting: boolean;
  29502. private _useObjectSpaceNormalMap;
  29503. /**
  29504. * Allows using an object space normal map (instead of tangent space).
  29505. */
  29506. useObjectSpaceNormalMap: boolean;
  29507. private _useParallax;
  29508. /**
  29509. * Is parallax enabled or not.
  29510. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29511. */
  29512. useParallax: boolean;
  29513. private _useParallaxOcclusion;
  29514. /**
  29515. * Is parallax occlusion enabled or not.
  29516. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29517. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29518. */
  29519. useParallaxOcclusion: boolean;
  29520. /**
  29521. * 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.
  29522. */
  29523. parallaxScaleBias: number;
  29524. private _roughness;
  29525. /**
  29526. * Helps to define how blurry the reflections should appears in the material.
  29527. */
  29528. roughness: number;
  29529. /**
  29530. * In case of refraction, define the value of the index of refraction.
  29531. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29532. */
  29533. indexOfRefraction: number;
  29534. /**
  29535. * Invert the refraction texture alongside the y axis.
  29536. * It can be useful with procedural textures or probe for instance.
  29537. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29538. */
  29539. invertRefractionY: boolean;
  29540. /**
  29541. * Defines the alpha limits in alpha test mode.
  29542. */
  29543. alphaCutOff: number;
  29544. private _useLightmapAsShadowmap;
  29545. /**
  29546. * In case of light mapping, define whether the map contains light or shadow informations.
  29547. */
  29548. useLightmapAsShadowmap: boolean;
  29549. private _diffuseFresnelParameters;
  29550. /**
  29551. * Define the diffuse fresnel parameters of the material.
  29552. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29553. */
  29554. diffuseFresnelParameters: FresnelParameters;
  29555. private _opacityFresnelParameters;
  29556. /**
  29557. * Define the opacity fresnel parameters of the material.
  29558. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29559. */
  29560. opacityFresnelParameters: FresnelParameters;
  29561. private _reflectionFresnelParameters;
  29562. /**
  29563. * Define the reflection fresnel parameters of the material.
  29564. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29565. */
  29566. reflectionFresnelParameters: FresnelParameters;
  29567. private _refractionFresnelParameters;
  29568. /**
  29569. * Define the refraction fresnel parameters of the material.
  29570. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29571. */
  29572. refractionFresnelParameters: FresnelParameters;
  29573. private _emissiveFresnelParameters;
  29574. /**
  29575. * Define the emissive fresnel parameters of the material.
  29576. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29577. */
  29578. emissiveFresnelParameters: FresnelParameters;
  29579. private _useReflectionFresnelFromSpecular;
  29580. /**
  29581. * If true automatically deducts the fresnels values from the material specularity.
  29582. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29583. */
  29584. useReflectionFresnelFromSpecular: boolean;
  29585. private _useGlossinessFromSpecularMapAlpha;
  29586. /**
  29587. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29588. */
  29589. useGlossinessFromSpecularMapAlpha: boolean;
  29590. private _maxSimultaneousLights;
  29591. /**
  29592. * Defines the maximum number of lights that can be used in the material
  29593. */
  29594. maxSimultaneousLights: number;
  29595. private _invertNormalMapX;
  29596. /**
  29597. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29598. */
  29599. invertNormalMapX: boolean;
  29600. private _invertNormalMapY;
  29601. /**
  29602. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29603. */
  29604. invertNormalMapY: boolean;
  29605. private _twoSidedLighting;
  29606. /**
  29607. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29608. */
  29609. twoSidedLighting: boolean;
  29610. /**
  29611. * Default configuration related to image processing available in the standard Material.
  29612. */
  29613. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29614. /**
  29615. * Gets the image processing configuration used either in this material.
  29616. */
  29617. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29618. /**
  29619. * Sets the Default image processing configuration used either in the this material.
  29620. *
  29621. * If sets to null, the scene one is in use.
  29622. */
  29623. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29624. /**
  29625. * Keep track of the image processing observer to allow dispose and replace.
  29626. */
  29627. private _imageProcessingObserver;
  29628. /**
  29629. * Attaches a new image processing configuration to the Standard Material.
  29630. * @param configuration
  29631. */
  29632. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29633. /**
  29634. * Gets wether the color curves effect is enabled.
  29635. */
  29636. get cameraColorCurvesEnabled(): boolean;
  29637. /**
  29638. * Sets wether the color curves effect is enabled.
  29639. */
  29640. set cameraColorCurvesEnabled(value: boolean);
  29641. /**
  29642. * Gets wether the color grading effect is enabled.
  29643. */
  29644. get cameraColorGradingEnabled(): boolean;
  29645. /**
  29646. * Gets wether the color grading effect is enabled.
  29647. */
  29648. set cameraColorGradingEnabled(value: boolean);
  29649. /**
  29650. * Gets wether tonemapping is enabled or not.
  29651. */
  29652. get cameraToneMappingEnabled(): boolean;
  29653. /**
  29654. * Sets wether tonemapping is enabled or not
  29655. */
  29656. set cameraToneMappingEnabled(value: boolean);
  29657. /**
  29658. * The camera exposure used on this material.
  29659. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29660. * This corresponds to a photographic exposure.
  29661. */
  29662. get cameraExposure(): number;
  29663. /**
  29664. * The camera exposure used on this material.
  29665. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29666. * This corresponds to a photographic exposure.
  29667. */
  29668. set cameraExposure(value: number);
  29669. /**
  29670. * Gets The camera contrast used on this material.
  29671. */
  29672. get cameraContrast(): number;
  29673. /**
  29674. * Sets The camera contrast used on this material.
  29675. */
  29676. set cameraContrast(value: number);
  29677. /**
  29678. * Gets the Color Grading 2D Lookup Texture.
  29679. */
  29680. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29681. /**
  29682. * Sets the Color Grading 2D Lookup Texture.
  29683. */
  29684. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29685. /**
  29686. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29687. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29688. * 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;
  29689. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29690. */
  29691. get cameraColorCurves(): Nullable<ColorCurves>;
  29692. /**
  29693. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29694. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29695. * 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;
  29696. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29697. */
  29698. set cameraColorCurves(value: Nullable<ColorCurves>);
  29699. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29700. protected _worldViewProjectionMatrix: Matrix;
  29701. protected _globalAmbientColor: Color3;
  29702. protected _useLogarithmicDepth: boolean;
  29703. protected _rebuildInParallel: boolean;
  29704. /**
  29705. * Instantiates a new standard material.
  29706. * This is the default material used in Babylon. It is the best trade off between quality
  29707. * and performances.
  29708. * @see http://doc.babylonjs.com/babylon101/materials
  29709. * @param name Define the name of the material in the scene
  29710. * @param scene Define the scene the material belong to
  29711. */
  29712. constructor(name: string, scene: Scene);
  29713. /**
  29714. * Gets a boolean indicating that current material needs to register RTT
  29715. */
  29716. get hasRenderTargetTextures(): boolean;
  29717. /**
  29718. * Gets the current class name of the material e.g. "StandardMaterial"
  29719. * Mainly use in serialization.
  29720. * @returns the class name
  29721. */
  29722. getClassName(): string;
  29723. /**
  29724. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29725. * You can try switching to logarithmic depth.
  29726. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29727. */
  29728. get useLogarithmicDepth(): boolean;
  29729. set useLogarithmicDepth(value: boolean);
  29730. /**
  29731. * Specifies if the material will require alpha blending
  29732. * @returns a boolean specifying if alpha blending is needed
  29733. */
  29734. needAlphaBlending(): boolean;
  29735. /**
  29736. * Specifies if this material should be rendered in alpha test mode
  29737. * @returns a boolean specifying if an alpha test is needed.
  29738. */
  29739. needAlphaTesting(): boolean;
  29740. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29741. /**
  29742. * Get the texture used for alpha test purpose.
  29743. * @returns the diffuse texture in case of the standard material.
  29744. */
  29745. getAlphaTestTexture(): Nullable<BaseTexture>;
  29746. /**
  29747. * Get if the submesh is ready to be used and all its information available.
  29748. * Child classes can use it to update shaders
  29749. * @param mesh defines the mesh to check
  29750. * @param subMesh defines which submesh to check
  29751. * @param useInstances specifies that instances should be used
  29752. * @returns a boolean indicating that the submesh is ready or not
  29753. */
  29754. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29755. /**
  29756. * Builds the material UBO layouts.
  29757. * Used internally during the effect preparation.
  29758. */
  29759. buildUniformLayout(): void;
  29760. /**
  29761. * Unbinds the material from the mesh
  29762. */
  29763. unbind(): void;
  29764. /**
  29765. * Binds the submesh to this material by preparing the effect and shader to draw
  29766. * @param world defines the world transformation matrix
  29767. * @param mesh defines the mesh containing the submesh
  29768. * @param subMesh defines the submesh to bind the material to
  29769. */
  29770. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29771. /**
  29772. * Get the list of animatables in the material.
  29773. * @returns the list of animatables object used in the material
  29774. */
  29775. getAnimatables(): IAnimatable[];
  29776. /**
  29777. * Gets the active textures from the material
  29778. * @returns an array of textures
  29779. */
  29780. getActiveTextures(): BaseTexture[];
  29781. /**
  29782. * Specifies if the material uses a texture
  29783. * @param texture defines the texture to check against the material
  29784. * @returns a boolean specifying if the material uses the texture
  29785. */
  29786. hasTexture(texture: BaseTexture): boolean;
  29787. /**
  29788. * Disposes the material
  29789. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29790. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29791. */
  29792. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29793. /**
  29794. * Makes a duplicate of the material, and gives it a new name
  29795. * @param name defines the new name for the duplicated material
  29796. * @returns the cloned material
  29797. */
  29798. clone(name: string): StandardMaterial;
  29799. /**
  29800. * Serializes this material in a JSON representation
  29801. * @returns the serialized material object
  29802. */
  29803. serialize(): any;
  29804. /**
  29805. * Creates a standard material from parsed material data
  29806. * @param source defines the JSON representation of the material
  29807. * @param scene defines the hosting scene
  29808. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29809. * @returns a new standard material
  29810. */
  29811. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29812. /**
  29813. * Are diffuse textures enabled in the application.
  29814. */
  29815. static get DiffuseTextureEnabled(): boolean;
  29816. static set DiffuseTextureEnabled(value: boolean);
  29817. /**
  29818. * Are ambient textures enabled in the application.
  29819. */
  29820. static get AmbientTextureEnabled(): boolean;
  29821. static set AmbientTextureEnabled(value: boolean);
  29822. /**
  29823. * Are opacity textures enabled in the application.
  29824. */
  29825. static get OpacityTextureEnabled(): boolean;
  29826. static set OpacityTextureEnabled(value: boolean);
  29827. /**
  29828. * Are reflection textures enabled in the application.
  29829. */
  29830. static get ReflectionTextureEnabled(): boolean;
  29831. static set ReflectionTextureEnabled(value: boolean);
  29832. /**
  29833. * Are emissive textures enabled in the application.
  29834. */
  29835. static get EmissiveTextureEnabled(): boolean;
  29836. static set EmissiveTextureEnabled(value: boolean);
  29837. /**
  29838. * Are specular textures enabled in the application.
  29839. */
  29840. static get SpecularTextureEnabled(): boolean;
  29841. static set SpecularTextureEnabled(value: boolean);
  29842. /**
  29843. * Are bump textures enabled in the application.
  29844. */
  29845. static get BumpTextureEnabled(): boolean;
  29846. static set BumpTextureEnabled(value: boolean);
  29847. /**
  29848. * Are lightmap textures enabled in the application.
  29849. */
  29850. static get LightmapTextureEnabled(): boolean;
  29851. static set LightmapTextureEnabled(value: boolean);
  29852. /**
  29853. * Are refraction textures enabled in the application.
  29854. */
  29855. static get RefractionTextureEnabled(): boolean;
  29856. static set RefractionTextureEnabled(value: boolean);
  29857. /**
  29858. * Are color grading textures enabled in the application.
  29859. */
  29860. static get ColorGradingTextureEnabled(): boolean;
  29861. static set ColorGradingTextureEnabled(value: boolean);
  29862. /**
  29863. * Are fresnels enabled in the application.
  29864. */
  29865. static get FresnelEnabled(): boolean;
  29866. static set FresnelEnabled(value: boolean);
  29867. }
  29868. }
  29869. declare module BABYLON {
  29870. /**
  29871. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  29872. *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.
  29873. * The SPS is also a particle system. It provides some methods to manage the particles.
  29874. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  29875. *
  29876. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  29877. */
  29878. export class SolidParticleSystem implements IDisposable {
  29879. /**
  29880. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  29881. * Example : var p = SPS.particles[i];
  29882. */
  29883. particles: SolidParticle[];
  29884. /**
  29885. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  29886. */
  29887. nbParticles: number;
  29888. /**
  29889. * If the particles must ever face the camera (default false). Useful for planar particles.
  29890. */
  29891. billboard: boolean;
  29892. /**
  29893. * Recompute normals when adding a shape
  29894. */
  29895. recomputeNormals: boolean;
  29896. /**
  29897. * This a counter ofr your own usage. It's not set by any SPS functions.
  29898. */
  29899. counter: number;
  29900. /**
  29901. * The SPS name. This name is also given to the underlying mesh.
  29902. */
  29903. name: string;
  29904. /**
  29905. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  29906. */
  29907. mesh: Mesh;
  29908. /**
  29909. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  29910. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  29911. */
  29912. vars: any;
  29913. /**
  29914. * This array is populated when the SPS is set as 'pickable'.
  29915. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  29916. * Each element of this array is an object `{idx: int, faceId: int}`.
  29917. * `idx` is the picked particle index in the `SPS.particles` array
  29918. * `faceId` is the picked face index counted within this particle.
  29919. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  29920. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  29921. * Use the method SPS.pickedParticle(pickingInfo) instead.
  29922. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29923. */
  29924. pickedParticles: {
  29925. idx: number;
  29926. faceId: number;
  29927. }[];
  29928. /**
  29929. * This array is populated when the SPS is set as 'pickable'
  29930. * Each key of this array is a submesh index.
  29931. * Each element of this array is a second array defined like this :
  29932. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  29933. * Each element of this second array is an object `{idx: int, faceId: int}`.
  29934. * `idx` is the picked particle index in the `SPS.particles` array
  29935. * `faceId` is the picked face index counted within this particle.
  29936. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  29937. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29938. */
  29939. pickedBySubMesh: {
  29940. idx: number;
  29941. faceId: number;
  29942. }[][];
  29943. /**
  29944. * This array is populated when `enableDepthSort` is set to true.
  29945. * Each element of this array is an instance of the class DepthSortedParticle.
  29946. */
  29947. depthSortedParticles: DepthSortedParticle[];
  29948. /**
  29949. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  29950. * @hidden
  29951. */
  29952. _bSphereOnly: boolean;
  29953. /**
  29954. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  29955. * @hidden
  29956. */
  29957. _bSphereRadiusFactor: number;
  29958. private _scene;
  29959. private _positions;
  29960. private _indices;
  29961. private _normals;
  29962. private _colors;
  29963. private _uvs;
  29964. private _indices32;
  29965. private _positions32;
  29966. private _normals32;
  29967. private _fixedNormal32;
  29968. private _colors32;
  29969. private _uvs32;
  29970. private _index;
  29971. private _updatable;
  29972. private _pickable;
  29973. private _isVisibilityBoxLocked;
  29974. private _alwaysVisible;
  29975. private _depthSort;
  29976. private _expandable;
  29977. private _shapeCounter;
  29978. private _copy;
  29979. private _color;
  29980. private _computeParticleColor;
  29981. private _computeParticleTexture;
  29982. private _computeParticleRotation;
  29983. private _computeParticleVertex;
  29984. private _computeBoundingBox;
  29985. private _depthSortParticles;
  29986. private _camera;
  29987. private _mustUnrotateFixedNormals;
  29988. private _particlesIntersect;
  29989. private _needs32Bits;
  29990. private _isNotBuilt;
  29991. private _lastParticleId;
  29992. private _idxOfId;
  29993. private _multimaterialEnabled;
  29994. private _useModelMaterial;
  29995. private _indicesByMaterial;
  29996. private _materialIndexes;
  29997. private _depthSortFunction;
  29998. private _materialSortFunction;
  29999. private _materials;
  30000. private _multimaterial;
  30001. private _materialIndexesById;
  30002. private _defaultMaterial;
  30003. private _autoUpdateSubMeshes;
  30004. private _tmpVertex;
  30005. /**
  30006. * Creates a SPS (Solid Particle System) object.
  30007. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30008. * @param scene (Scene) is the scene in which the SPS is added.
  30009. * @param options defines the options of the sps e.g.
  30010. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30011. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30012. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30013. * * 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.
  30014. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30015. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30016. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30017. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30018. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30019. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30020. */
  30021. constructor(name: string, scene: Scene, options?: {
  30022. updatable?: boolean;
  30023. isPickable?: boolean;
  30024. enableDepthSort?: boolean;
  30025. particleIntersection?: boolean;
  30026. boundingSphereOnly?: boolean;
  30027. bSphereRadiusFactor?: number;
  30028. expandable?: boolean;
  30029. useModelMaterial?: boolean;
  30030. enableMultiMaterial?: boolean;
  30031. });
  30032. /**
  30033. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30034. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30035. * @returns the created mesh
  30036. */
  30037. buildMesh(): Mesh;
  30038. /**
  30039. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30040. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30041. * Thus the particles generated from `digest()` have their property `position` set yet.
  30042. * @param mesh ( Mesh ) is the mesh to be digested
  30043. * @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
  30044. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30045. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30046. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30047. * @returns the current SPS
  30048. */
  30049. digest(mesh: Mesh, options?: {
  30050. facetNb?: number;
  30051. number?: number;
  30052. delta?: number;
  30053. storage?: [];
  30054. }): SolidParticleSystem;
  30055. /**
  30056. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30057. * @hidden
  30058. */
  30059. private _unrotateFixedNormals;
  30060. /**
  30061. * Resets the temporary working copy particle
  30062. * @hidden
  30063. */
  30064. private _resetCopy;
  30065. /**
  30066. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30067. * @param p the current index in the positions array to be updated
  30068. * @param ind the current index in the indices array
  30069. * @param shape a Vector3 array, the shape geometry
  30070. * @param positions the positions array to be updated
  30071. * @param meshInd the shape indices array
  30072. * @param indices the indices array to be updated
  30073. * @param meshUV the shape uv array
  30074. * @param uvs the uv array to be updated
  30075. * @param meshCol the shape color array
  30076. * @param colors the color array to be updated
  30077. * @param meshNor the shape normals array
  30078. * @param normals the normals array to be updated
  30079. * @param idx the particle index
  30080. * @param idxInShape the particle index in its shape
  30081. * @param options the addShape() method passed options
  30082. * @model the particle model
  30083. * @hidden
  30084. */
  30085. private _meshBuilder;
  30086. /**
  30087. * Returns a shape Vector3 array from positions float array
  30088. * @param positions float array
  30089. * @returns a vector3 array
  30090. * @hidden
  30091. */
  30092. private _posToShape;
  30093. /**
  30094. * Returns a shapeUV array from a float uvs (array deep copy)
  30095. * @param uvs as a float array
  30096. * @returns a shapeUV array
  30097. * @hidden
  30098. */
  30099. private _uvsToShapeUV;
  30100. /**
  30101. * Adds a new particle object in the particles array
  30102. * @param idx particle index in particles array
  30103. * @param id particle id
  30104. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30105. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30106. * @param model particle ModelShape object
  30107. * @param shapeId model shape identifier
  30108. * @param idxInShape index of the particle in the current model
  30109. * @param bInfo model bounding info object
  30110. * @param storage target storage array, if any
  30111. * @hidden
  30112. */
  30113. private _addParticle;
  30114. /**
  30115. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30116. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30117. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30118. * @param nb (positive integer) the number of particles to be created from this model
  30119. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30120. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30121. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30122. * @returns the number of shapes in the system
  30123. */
  30124. addShape(mesh: Mesh, nb: number, options?: {
  30125. positionFunction?: any;
  30126. vertexFunction?: any;
  30127. storage?: [];
  30128. }): number;
  30129. /**
  30130. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30131. * @hidden
  30132. */
  30133. private _rebuildParticle;
  30134. /**
  30135. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30136. * @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.
  30137. * @returns the SPS.
  30138. */
  30139. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30140. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30141. * Returns an array with the removed particles.
  30142. * 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.
  30143. * The SPS can't be empty so at least one particle needs to remain in place.
  30144. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30145. * @param start index of the first particle to remove
  30146. * @param end index of the last particle to remove (included)
  30147. * @returns an array populated with the removed particles
  30148. */
  30149. removeParticles(start: number, end: number): SolidParticle[];
  30150. /**
  30151. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30152. * @param solidParticleArray an array populated with Solid Particles objects
  30153. * @returns the SPS
  30154. */
  30155. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30156. /**
  30157. * Creates a new particle and modifies the SPS mesh geometry :
  30158. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30159. * - calls _addParticle() to populate the particle array
  30160. * factorized code from addShape() and insertParticlesFromArray()
  30161. * @param idx particle index in the particles array
  30162. * @param i particle index in its shape
  30163. * @param modelShape particle ModelShape object
  30164. * @param shape shape vertex array
  30165. * @param meshInd shape indices array
  30166. * @param meshUV shape uv array
  30167. * @param meshCol shape color array
  30168. * @param meshNor shape normals array
  30169. * @param bbInfo shape bounding info
  30170. * @param storage target particle storage
  30171. * @options addShape() passed options
  30172. * @hidden
  30173. */
  30174. private _insertNewParticle;
  30175. /**
  30176. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30177. * This method calls `updateParticle()` for each particle of the SPS.
  30178. * For an animated SPS, it is usually called within the render loop.
  30179. * 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.
  30180. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30181. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30182. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30183. * @returns the SPS.
  30184. */
  30185. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30186. /**
  30187. * Disposes the SPS.
  30188. */
  30189. dispose(): void;
  30190. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30191. * idx is the particle index in the SPS
  30192. * faceId is the picked face index counted within this particle.
  30193. * Returns null if the pickInfo can't identify a picked particle.
  30194. * @param pickingInfo (PickingInfo object)
  30195. * @returns {idx: number, faceId: number} or null
  30196. */
  30197. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30198. idx: number;
  30199. faceId: number;
  30200. }>;
  30201. /**
  30202. * Returns a SolidParticle object from its identifier : particle.id
  30203. * @param id (integer) the particle Id
  30204. * @returns the searched particle or null if not found in the SPS.
  30205. */
  30206. getParticleById(id: number): Nullable<SolidParticle>;
  30207. /**
  30208. * Returns a new array populated with the particles having the passed shapeId.
  30209. * @param shapeId (integer) the shape identifier
  30210. * @returns a new solid particle array
  30211. */
  30212. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30213. /**
  30214. * Populates the passed array "ref" with the particles having the passed shapeId.
  30215. * @param shapeId the shape identifier
  30216. * @returns the SPS
  30217. * @param ref
  30218. */
  30219. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30220. /**
  30221. * Computes the required SubMeshes according the materials assigned to the particles.
  30222. * @returns the solid particle system.
  30223. * Does nothing if called before the SPS mesh is built.
  30224. */
  30225. computeSubMeshes(): SolidParticleSystem;
  30226. /**
  30227. * Sorts the solid particles by material when MultiMaterial is enabled.
  30228. * Updates the indices32 array.
  30229. * Updates the indicesByMaterial array.
  30230. * Updates the mesh indices array.
  30231. * @returns the SPS
  30232. * @hidden
  30233. */
  30234. private _sortParticlesByMaterial;
  30235. /**
  30236. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30237. * @hidden
  30238. */
  30239. private _setMaterialIndexesById;
  30240. /**
  30241. * Returns an array with unique values of Materials from the passed array
  30242. * @param array the material array to be checked and filtered
  30243. * @hidden
  30244. */
  30245. private _filterUniqueMaterialId;
  30246. /**
  30247. * Sets a new Standard Material as _defaultMaterial if not already set.
  30248. * @hidden
  30249. */
  30250. private _setDefaultMaterial;
  30251. /**
  30252. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30253. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30254. * @returns the SPS.
  30255. */
  30256. refreshVisibleSize(): SolidParticleSystem;
  30257. /**
  30258. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30259. * @param size the size (float) of the visibility box
  30260. * note : this doesn't lock the SPS mesh bounding box.
  30261. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30262. */
  30263. setVisibilityBox(size: number): void;
  30264. /**
  30265. * Gets whether the SPS as always visible or not
  30266. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30267. */
  30268. get isAlwaysVisible(): boolean;
  30269. /**
  30270. * Sets the SPS as always visible or not
  30271. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30272. */
  30273. set isAlwaysVisible(val: boolean);
  30274. /**
  30275. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30276. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30277. */
  30278. set isVisibilityBoxLocked(val: boolean);
  30279. /**
  30280. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30281. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30282. */
  30283. get isVisibilityBoxLocked(): boolean;
  30284. /**
  30285. * Tells to `setParticles()` to compute the particle rotations or not.
  30286. * Default value : true. The SPS is faster when it's set to false.
  30287. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30288. */
  30289. set computeParticleRotation(val: boolean);
  30290. /**
  30291. * Tells to `setParticles()` to compute the particle colors or not.
  30292. * Default value : true. The SPS is faster when it's set to false.
  30293. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30294. */
  30295. set computeParticleColor(val: boolean);
  30296. set computeParticleTexture(val: boolean);
  30297. /**
  30298. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30299. * Default value : false. The SPS is faster when it's set to false.
  30300. * Note : the particle custom vertex positions aren't stored values.
  30301. */
  30302. set computeParticleVertex(val: boolean);
  30303. /**
  30304. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30305. */
  30306. set computeBoundingBox(val: boolean);
  30307. /**
  30308. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30309. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30310. * Default : `true`
  30311. */
  30312. set depthSortParticles(val: boolean);
  30313. /**
  30314. * Gets if `setParticles()` computes the particle rotations or not.
  30315. * Default value : true. The SPS is faster when it's set to false.
  30316. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30317. */
  30318. get computeParticleRotation(): boolean;
  30319. /**
  30320. * Gets if `setParticles()` computes the particle colors or not.
  30321. * Default value : true. The SPS is faster when it's set to false.
  30322. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30323. */
  30324. get computeParticleColor(): boolean;
  30325. /**
  30326. * Gets if `setParticles()` computes the particle textures or not.
  30327. * Default value : true. The SPS is faster when it's set to false.
  30328. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30329. */
  30330. get computeParticleTexture(): boolean;
  30331. /**
  30332. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30333. * Default value : false. The SPS is faster when it's set to false.
  30334. * Note : the particle custom vertex positions aren't stored values.
  30335. */
  30336. get computeParticleVertex(): boolean;
  30337. /**
  30338. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30339. */
  30340. get computeBoundingBox(): boolean;
  30341. /**
  30342. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30343. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30344. * Default : `true`
  30345. */
  30346. get depthSortParticles(): boolean;
  30347. /**
  30348. * Gets if the SPS is created as expandable at construction time.
  30349. * Default : `false`
  30350. */
  30351. get expandable(): boolean;
  30352. /**
  30353. * Gets if the SPS supports the Multi Materials
  30354. */
  30355. get multimaterialEnabled(): boolean;
  30356. /**
  30357. * Gets if the SPS uses the model materials for its own multimaterial.
  30358. */
  30359. get useModelMaterial(): boolean;
  30360. /**
  30361. * The SPS used material array.
  30362. */
  30363. get materials(): Material[];
  30364. /**
  30365. * Sets the SPS MultiMaterial from the passed materials.
  30366. * Note : the passed array is internally copied and not used then by reference.
  30367. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30368. */
  30369. setMultiMaterial(materials: Material[]): void;
  30370. /**
  30371. * The SPS computed multimaterial object
  30372. */
  30373. get multimaterial(): MultiMaterial;
  30374. set multimaterial(mm: MultiMaterial);
  30375. /**
  30376. * If the subMeshes must be updated on the next call to setParticles()
  30377. */
  30378. get autoUpdateSubMeshes(): boolean;
  30379. set autoUpdateSubMeshes(val: boolean);
  30380. /**
  30381. * This function does nothing. It may be overwritten to set all the particle first values.
  30382. * The SPS doesn't call this function, you may have to call it by your own.
  30383. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30384. */
  30385. initParticles(): void;
  30386. /**
  30387. * This function does nothing. It may be overwritten to recycle a particle.
  30388. * The SPS doesn't call this function, you may have to call it by your own.
  30389. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30390. * @param particle The particle to recycle
  30391. * @returns the recycled particle
  30392. */
  30393. recycleParticle(particle: SolidParticle): SolidParticle;
  30394. /**
  30395. * Updates a particle : this function should be overwritten by the user.
  30396. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30397. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30398. * @example : just set a particle position or velocity and recycle conditions
  30399. * @param particle The particle to update
  30400. * @returns the updated particle
  30401. */
  30402. updateParticle(particle: SolidParticle): SolidParticle;
  30403. /**
  30404. * Updates a vertex of a particle : it can be overwritten by the user.
  30405. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30406. * @param particle the current particle
  30407. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30408. * @param pt the index of the current vertex in the particle shape
  30409. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30410. * @example : just set a vertex particle position or color
  30411. * @returns the sps
  30412. */
  30413. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30414. /**
  30415. * This will be called before any other treatment by `setParticles()` and 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. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30422. /**
  30423. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30424. * This will be passed three parameters.
  30425. * This does nothing and may be overwritten by the user.
  30426. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30427. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30428. * @param update the boolean update value actually passed to setParticles()
  30429. */
  30430. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30431. }
  30432. }
  30433. declare module BABYLON {
  30434. /**
  30435. * Represents one particle of a solid particle system.
  30436. */
  30437. export class SolidParticle {
  30438. /**
  30439. * particle global index
  30440. */
  30441. idx: number;
  30442. /**
  30443. * particle identifier
  30444. */
  30445. id: number;
  30446. /**
  30447. * The color of the particle
  30448. */
  30449. color: Nullable<Color4>;
  30450. /**
  30451. * The world space position of the particle.
  30452. */
  30453. position: Vector3;
  30454. /**
  30455. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30456. */
  30457. rotation: Vector3;
  30458. /**
  30459. * The world space rotation quaternion of the particle.
  30460. */
  30461. rotationQuaternion: Nullable<Quaternion>;
  30462. /**
  30463. * The scaling of the particle.
  30464. */
  30465. scaling: Vector3;
  30466. /**
  30467. * The uvs of the particle.
  30468. */
  30469. uvs: Vector4;
  30470. /**
  30471. * The current speed of the particle.
  30472. */
  30473. velocity: Vector3;
  30474. /**
  30475. * The pivot point in the particle local space.
  30476. */
  30477. pivot: Vector3;
  30478. /**
  30479. * Must the particle be translated from its pivot point in its local space ?
  30480. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30481. * Default : false
  30482. */
  30483. translateFromPivot: boolean;
  30484. /**
  30485. * Is the particle active or not ?
  30486. */
  30487. alive: boolean;
  30488. /**
  30489. * Is the particle visible or not ?
  30490. */
  30491. isVisible: boolean;
  30492. /**
  30493. * Index of this particle in the global "positions" array (Internal use)
  30494. * @hidden
  30495. */
  30496. _pos: number;
  30497. /**
  30498. * @hidden Index of this particle in the global "indices" array (Internal use)
  30499. */
  30500. _ind: number;
  30501. /**
  30502. * @hidden ModelShape of this particle (Internal use)
  30503. */
  30504. _model: ModelShape;
  30505. /**
  30506. * ModelShape id of this particle
  30507. */
  30508. shapeId: number;
  30509. /**
  30510. * Index of the particle in its shape id
  30511. */
  30512. idxInShape: number;
  30513. /**
  30514. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30515. */
  30516. _modelBoundingInfo: BoundingInfo;
  30517. /**
  30518. * @hidden Particle BoundingInfo object (Internal use)
  30519. */
  30520. _boundingInfo: BoundingInfo;
  30521. /**
  30522. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30523. */
  30524. _sps: SolidParticleSystem;
  30525. /**
  30526. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30527. */
  30528. _stillInvisible: boolean;
  30529. /**
  30530. * @hidden Last computed particle rotation matrix
  30531. */
  30532. _rotationMatrix: number[];
  30533. /**
  30534. * Parent particle Id, if any.
  30535. * Default null.
  30536. */
  30537. parentId: Nullable<number>;
  30538. /**
  30539. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30540. */
  30541. materialIndex: Nullable<number>;
  30542. /**
  30543. * Custom object or properties.
  30544. */
  30545. props: Nullable<any>;
  30546. /**
  30547. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30548. * The possible values are :
  30549. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30550. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30551. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30552. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30553. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30554. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30555. * */
  30556. cullingStrategy: number;
  30557. /**
  30558. * @hidden Internal global position in the SPS.
  30559. */
  30560. _globalPosition: Vector3;
  30561. /**
  30562. * Creates a Solid Particle object.
  30563. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30564. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30565. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30566. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30567. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30568. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30569. * @param shapeId (integer) is the model shape identifier in the SPS.
  30570. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30571. * @param sps defines the sps it is associated to
  30572. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30573. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30574. */
  30575. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30576. /**
  30577. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30578. * @param target the particle target
  30579. * @returns the current particle
  30580. */
  30581. copyToRef(target: SolidParticle): SolidParticle;
  30582. /**
  30583. * Legacy support, changed scale to scaling
  30584. */
  30585. get scale(): Vector3;
  30586. /**
  30587. * Legacy support, changed scale to scaling
  30588. */
  30589. set scale(scale: Vector3);
  30590. /**
  30591. * Legacy support, changed quaternion to rotationQuaternion
  30592. */
  30593. get quaternion(): Nullable<Quaternion>;
  30594. /**
  30595. * Legacy support, changed quaternion to rotationQuaternion
  30596. */
  30597. set quaternion(q: Nullable<Quaternion>);
  30598. /**
  30599. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30600. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30601. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30602. * @returns true if it intersects
  30603. */
  30604. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30605. /**
  30606. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30607. * A particle is in the frustum if its bounding box intersects the frustum
  30608. * @param frustumPlanes defines the frustum to test
  30609. * @returns true if the particle is in the frustum planes
  30610. */
  30611. isInFrustum(frustumPlanes: Plane[]): boolean;
  30612. /**
  30613. * get the rotation matrix of the particle
  30614. * @hidden
  30615. */
  30616. getRotationMatrix(m: Matrix): void;
  30617. }
  30618. /**
  30619. * Represents the shape of the model used by one particle of a solid particle system.
  30620. * SPS internal tool, don't use it manually.
  30621. */
  30622. export class ModelShape {
  30623. /**
  30624. * The shape id
  30625. * @hidden
  30626. */
  30627. shapeID: number;
  30628. /**
  30629. * flat array of model positions (internal use)
  30630. * @hidden
  30631. */
  30632. _shape: Vector3[];
  30633. /**
  30634. * flat array of model UVs (internal use)
  30635. * @hidden
  30636. */
  30637. _shapeUV: number[];
  30638. /**
  30639. * color array of the model
  30640. * @hidden
  30641. */
  30642. _shapeColors: number[];
  30643. /**
  30644. * indices array of the model
  30645. * @hidden
  30646. */
  30647. _indices: number[];
  30648. /**
  30649. * normals array of the model
  30650. * @hidden
  30651. */
  30652. _normals: number[];
  30653. /**
  30654. * length of the shape in the model indices array (internal use)
  30655. * @hidden
  30656. */
  30657. _indicesLength: number;
  30658. /**
  30659. * Custom position function (internal use)
  30660. * @hidden
  30661. */
  30662. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30663. /**
  30664. * Custom vertex function (internal use)
  30665. * @hidden
  30666. */
  30667. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30668. /**
  30669. * Model material (internal use)
  30670. * @hidden
  30671. */
  30672. _material: Nullable<Material>;
  30673. /**
  30674. * 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.
  30675. * SPS internal tool, don't use it manually.
  30676. * @hidden
  30677. */
  30678. 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>);
  30679. }
  30680. /**
  30681. * Represents a Depth Sorted Particle in the solid particle system.
  30682. * @hidden
  30683. */
  30684. export class DepthSortedParticle {
  30685. /**
  30686. * Particle index
  30687. */
  30688. idx: number;
  30689. /**
  30690. * Index of the particle in the "indices" array
  30691. */
  30692. ind: number;
  30693. /**
  30694. * Length of the particle shape in the "indices" array
  30695. */
  30696. indicesLength: number;
  30697. /**
  30698. * Squared distance from the particle to the camera
  30699. */
  30700. sqDistance: number;
  30701. /**
  30702. * Material index when used with MultiMaterials
  30703. */
  30704. materialIndex: number;
  30705. /**
  30706. * Creates a new sorted particle
  30707. * @param materialIndex
  30708. */
  30709. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30710. }
  30711. /**
  30712. * Represents a solid particle vertex
  30713. */
  30714. export class SolidParticleVertex {
  30715. /**
  30716. * Vertex position
  30717. */
  30718. position: Vector3;
  30719. /**
  30720. * Vertex color
  30721. */
  30722. color: Color4;
  30723. /**
  30724. * Vertex UV
  30725. */
  30726. uv: Vector2;
  30727. /**
  30728. * Creates a new solid particle vertex
  30729. */
  30730. constructor();
  30731. /** Vertex x coordinate */
  30732. get x(): number;
  30733. set x(val: number);
  30734. /** Vertex y coordinate */
  30735. get y(): number;
  30736. set y(val: number);
  30737. /** Vertex z coordinate */
  30738. get z(): number;
  30739. set z(val: number);
  30740. }
  30741. }
  30742. declare module BABYLON {
  30743. /**
  30744. * @hidden
  30745. */
  30746. export class _MeshCollisionData {
  30747. _checkCollisions: boolean;
  30748. _collisionMask: number;
  30749. _collisionGroup: number;
  30750. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30751. _collider: Nullable<Collider>;
  30752. _oldPositionForCollisions: Vector3;
  30753. _diffPositionForCollisions: Vector3;
  30754. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30755. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30756. }
  30757. }
  30758. declare module BABYLON {
  30759. /** @hidden */
  30760. class _FacetDataStorage {
  30761. facetPositions: Vector3[];
  30762. facetNormals: Vector3[];
  30763. facetPartitioning: number[][];
  30764. facetNb: number;
  30765. partitioningSubdivisions: number;
  30766. partitioningBBoxRatio: number;
  30767. facetDataEnabled: boolean;
  30768. facetParameters: any;
  30769. bbSize: Vector3;
  30770. subDiv: {
  30771. max: number;
  30772. X: number;
  30773. Y: number;
  30774. Z: number;
  30775. };
  30776. facetDepthSort: boolean;
  30777. facetDepthSortEnabled: boolean;
  30778. depthSortedIndices: IndicesArray;
  30779. depthSortedFacets: {
  30780. ind: number;
  30781. sqDistance: number;
  30782. }[];
  30783. facetDepthSortFunction: (f1: {
  30784. ind: number;
  30785. sqDistance: number;
  30786. }, f2: {
  30787. ind: number;
  30788. sqDistance: number;
  30789. }) => number;
  30790. facetDepthSortFrom: Vector3;
  30791. facetDepthSortOrigin: Vector3;
  30792. invertedMatrix: Matrix;
  30793. }
  30794. /**
  30795. * @hidden
  30796. **/
  30797. class _InternalAbstractMeshDataInfo {
  30798. _hasVertexAlpha: boolean;
  30799. _useVertexColors: boolean;
  30800. _numBoneInfluencers: number;
  30801. _applyFog: boolean;
  30802. _receiveShadows: boolean;
  30803. _facetData: _FacetDataStorage;
  30804. _visibility: number;
  30805. _skeleton: Nullable<Skeleton>;
  30806. _layerMask: number;
  30807. _computeBonesUsingShaders: boolean;
  30808. _isActive: boolean;
  30809. _onlyForInstances: boolean;
  30810. _isActiveIntermediate: boolean;
  30811. _onlyForInstancesIntermediate: boolean;
  30812. _actAsRegularMesh: boolean;
  30813. }
  30814. /**
  30815. * Class used to store all common mesh properties
  30816. */
  30817. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30818. /** No occlusion */
  30819. static OCCLUSION_TYPE_NONE: number;
  30820. /** Occlusion set to optimisitic */
  30821. static OCCLUSION_TYPE_OPTIMISTIC: number;
  30822. /** Occlusion set to strict */
  30823. static OCCLUSION_TYPE_STRICT: number;
  30824. /** Use an accurante occlusion algorithm */
  30825. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  30826. /** Use a conservative occlusion algorithm */
  30827. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  30828. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30829. * Test order :
  30830. * Is the bounding sphere outside the frustum ?
  30831. * If not, are the bounding box vertices outside the frustum ?
  30832. * It not, then the cullable object is in the frustum.
  30833. */
  30834. static readonly CULLINGSTRATEGY_STANDARD: number;
  30835. /** Culling strategy : Bounding Sphere Only.
  30836. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30837. * It's also less accurate than the standard because some not visible objects can still be selected.
  30838. * Test : is the bounding sphere outside the frustum ?
  30839. * If not, then the cullable object is in the frustum.
  30840. */
  30841. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  30842. /** Culling strategy : Optimistic Inclusion.
  30843. * This in an inclusion test first, then the standard exclusion test.
  30844. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  30845. * 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.
  30846. * Anyway, it's as accurate as the standard strategy.
  30847. * Test :
  30848. * Is the cullable object bounding sphere center in the frustum ?
  30849. * If not, apply the default culling strategy.
  30850. */
  30851. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  30852. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  30853. * This in an inclusion test first, then the bounding sphere only exclusion test.
  30854. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  30855. * 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.
  30856. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  30857. * Test :
  30858. * Is the cullable object bounding sphere center in the frustum ?
  30859. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  30860. */
  30861. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  30862. /**
  30863. * No billboard
  30864. */
  30865. static get BILLBOARDMODE_NONE(): number;
  30866. /** Billboard on X axis */
  30867. static get BILLBOARDMODE_X(): number;
  30868. /** Billboard on Y axis */
  30869. static get BILLBOARDMODE_Y(): number;
  30870. /** Billboard on Z axis */
  30871. static get BILLBOARDMODE_Z(): number;
  30872. /** Billboard on all axes */
  30873. static get BILLBOARDMODE_ALL(): number;
  30874. /** Billboard on using position instead of orientation */
  30875. static get BILLBOARDMODE_USE_POSITION(): number;
  30876. /** @hidden */
  30877. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  30878. /**
  30879. * The culling strategy to use to check whether the mesh must be rendered or not.
  30880. * This value can be changed at any time and will be used on the next render mesh selection.
  30881. * The possible values are :
  30882. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30883. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30884. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30885. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30886. * Please read each static variable documentation to get details about the culling process.
  30887. * */
  30888. cullingStrategy: number;
  30889. /**
  30890. * Gets the number of facets in the mesh
  30891. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30892. */
  30893. get facetNb(): number;
  30894. /**
  30895. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  30896. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30897. */
  30898. get partitioningSubdivisions(): number;
  30899. set partitioningSubdivisions(nb: number);
  30900. /**
  30901. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  30902. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  30903. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30904. */
  30905. get partitioningBBoxRatio(): number;
  30906. set partitioningBBoxRatio(ratio: number);
  30907. /**
  30908. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  30909. * Works only for updatable meshes.
  30910. * Doesn't work with multi-materials
  30911. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30912. */
  30913. get mustDepthSortFacets(): boolean;
  30914. set mustDepthSortFacets(sort: boolean);
  30915. /**
  30916. * The location (Vector3) where the facet depth sort must be computed from.
  30917. * By default, the active camera position.
  30918. * Used only when facet depth sort is enabled
  30919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30920. */
  30921. get facetDepthSortFrom(): Vector3;
  30922. set facetDepthSortFrom(location: Vector3);
  30923. /**
  30924. * gets a boolean indicating if facetData is enabled
  30925. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30926. */
  30927. get isFacetDataEnabled(): boolean;
  30928. /** @hidden */
  30929. _updateNonUniformScalingState(value: boolean): boolean;
  30930. /**
  30931. * An event triggered when this mesh collides with another one
  30932. */
  30933. onCollideObservable: Observable<AbstractMesh>;
  30934. /** Set a function to call when this mesh collides with another one */
  30935. set onCollide(callback: () => void);
  30936. /**
  30937. * An event triggered when the collision's position changes
  30938. */
  30939. onCollisionPositionChangeObservable: Observable<Vector3>;
  30940. /** Set a function to call when the collision's position changes */
  30941. set onCollisionPositionChange(callback: () => void);
  30942. /**
  30943. * An event triggered when material is changed
  30944. */
  30945. onMaterialChangedObservable: Observable<AbstractMesh>;
  30946. /**
  30947. * Gets or sets the orientation for POV movement & rotation
  30948. */
  30949. definedFacingForward: boolean;
  30950. /** @hidden */
  30951. _occlusionQuery: Nullable<WebGLQuery>;
  30952. /** @hidden */
  30953. _renderingGroup: Nullable<RenderingGroup>;
  30954. /**
  30955. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30956. */
  30957. get visibility(): number;
  30958. /**
  30959. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30960. */
  30961. set visibility(value: number);
  30962. /** Gets or sets the alpha index used to sort transparent meshes
  30963. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  30964. */
  30965. alphaIndex: number;
  30966. /**
  30967. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  30968. */
  30969. isVisible: boolean;
  30970. /**
  30971. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  30972. */
  30973. isPickable: boolean;
  30974. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  30975. showSubMeshesBoundingBox: boolean;
  30976. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  30977. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  30978. */
  30979. isBlocker: boolean;
  30980. /**
  30981. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  30982. */
  30983. enablePointerMoveEvents: boolean;
  30984. /**
  30985. * Specifies the rendering group id for this mesh (0 by default)
  30986. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  30987. */
  30988. renderingGroupId: number;
  30989. private _material;
  30990. /** Gets or sets current material */
  30991. get material(): Nullable<Material>;
  30992. set material(value: Nullable<Material>);
  30993. /**
  30994. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  30995. * @see http://doc.babylonjs.com/babylon101/shadows
  30996. */
  30997. get receiveShadows(): boolean;
  30998. set receiveShadows(value: boolean);
  30999. /** Defines color to use when rendering outline */
  31000. outlineColor: Color3;
  31001. /** Define width to use when rendering outline */
  31002. outlineWidth: number;
  31003. /** Defines color to use when rendering overlay */
  31004. overlayColor: Color3;
  31005. /** Defines alpha to use when rendering overlay */
  31006. overlayAlpha: number;
  31007. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31008. get hasVertexAlpha(): boolean;
  31009. set hasVertexAlpha(value: boolean);
  31010. /** 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) */
  31011. get useVertexColors(): boolean;
  31012. set useVertexColors(value: boolean);
  31013. /**
  31014. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31015. */
  31016. get computeBonesUsingShaders(): boolean;
  31017. set computeBonesUsingShaders(value: boolean);
  31018. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31019. get numBoneInfluencers(): number;
  31020. set numBoneInfluencers(value: number);
  31021. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31022. get applyFog(): boolean;
  31023. set applyFog(value: boolean);
  31024. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31025. useOctreeForRenderingSelection: boolean;
  31026. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31027. useOctreeForPicking: boolean;
  31028. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31029. useOctreeForCollisions: boolean;
  31030. /**
  31031. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31032. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31033. */
  31034. get layerMask(): number;
  31035. set layerMask(value: number);
  31036. /**
  31037. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31038. */
  31039. alwaysSelectAsActiveMesh: boolean;
  31040. /**
  31041. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31042. */
  31043. doNotSyncBoundingInfo: boolean;
  31044. /**
  31045. * Gets or sets the current action manager
  31046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31047. */
  31048. actionManager: Nullable<AbstractActionManager>;
  31049. private _meshCollisionData;
  31050. /**
  31051. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31052. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31053. */
  31054. ellipsoid: Vector3;
  31055. /**
  31056. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31057. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31058. */
  31059. ellipsoidOffset: Vector3;
  31060. /**
  31061. * Gets or sets a collision mask used to mask collisions (default is -1).
  31062. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31063. */
  31064. get collisionMask(): number;
  31065. set collisionMask(mask: number);
  31066. /**
  31067. * Gets or sets the current collision group mask (-1 by default).
  31068. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31069. */
  31070. get collisionGroup(): number;
  31071. set collisionGroup(mask: number);
  31072. /**
  31073. * Gets or sets current surrounding meshes (null by default).
  31074. *
  31075. * By default collision detection is tested against every mesh in the scene.
  31076. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31077. * meshes will be tested for the collision.
  31078. *
  31079. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31080. */
  31081. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31082. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31083. /**
  31084. * Defines edge width used when edgesRenderer is enabled
  31085. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31086. */
  31087. edgesWidth: number;
  31088. /**
  31089. * Defines edge color used when edgesRenderer is enabled
  31090. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31091. */
  31092. edgesColor: Color4;
  31093. /** @hidden */
  31094. _edgesRenderer: Nullable<IEdgesRenderer>;
  31095. /** @hidden */
  31096. _masterMesh: Nullable<AbstractMesh>;
  31097. /** @hidden */
  31098. _boundingInfo: Nullable<BoundingInfo>;
  31099. /** @hidden */
  31100. _renderId: number;
  31101. /**
  31102. * Gets or sets the list of subMeshes
  31103. * @see http://doc.babylonjs.com/how_to/multi_materials
  31104. */
  31105. subMeshes: SubMesh[];
  31106. /** @hidden */
  31107. _intersectionsInProgress: AbstractMesh[];
  31108. /** @hidden */
  31109. _unIndexed: boolean;
  31110. /** @hidden */
  31111. _lightSources: Light[];
  31112. /** Gets the list of lights affecting that mesh */
  31113. get lightSources(): Light[];
  31114. /** @hidden */
  31115. get _positions(): Nullable<Vector3[]>;
  31116. /** @hidden */
  31117. _waitingData: {
  31118. lods: Nullable<any>;
  31119. actions: Nullable<any>;
  31120. freezeWorldMatrix: Nullable<boolean>;
  31121. };
  31122. /** @hidden */
  31123. _bonesTransformMatrices: Nullable<Float32Array>;
  31124. /** @hidden */
  31125. _transformMatrixTexture: Nullable<RawTexture>;
  31126. /**
  31127. * Gets or sets a skeleton to apply skining transformations
  31128. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31129. */
  31130. set skeleton(value: Nullable<Skeleton>);
  31131. get skeleton(): Nullable<Skeleton>;
  31132. /**
  31133. * An event triggered when the mesh is rebuilt.
  31134. */
  31135. onRebuildObservable: Observable<AbstractMesh>;
  31136. /**
  31137. * Creates a new AbstractMesh
  31138. * @param name defines the name of the mesh
  31139. * @param scene defines the hosting scene
  31140. */
  31141. constructor(name: string, scene?: Nullable<Scene>);
  31142. /**
  31143. * Returns the string "AbstractMesh"
  31144. * @returns "AbstractMesh"
  31145. */
  31146. getClassName(): string;
  31147. /**
  31148. * Gets a string representation of the current mesh
  31149. * @param fullDetails defines a boolean indicating if full details must be included
  31150. * @returns a string representation of the current mesh
  31151. */
  31152. toString(fullDetails?: boolean): string;
  31153. /**
  31154. * @hidden
  31155. */
  31156. protected _getEffectiveParent(): Nullable<Node>;
  31157. /** @hidden */
  31158. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31159. /** @hidden */
  31160. _rebuild(): void;
  31161. /** @hidden */
  31162. _resyncLightSources(): void;
  31163. /** @hidden */
  31164. _resyncLightSource(light: Light): void;
  31165. /** @hidden */
  31166. _unBindEffect(): void;
  31167. /** @hidden */
  31168. _removeLightSource(light: Light, dispose: boolean): void;
  31169. private _markSubMeshesAsDirty;
  31170. /** @hidden */
  31171. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31172. /** @hidden */
  31173. _markSubMeshesAsAttributesDirty(): void;
  31174. /** @hidden */
  31175. _markSubMeshesAsMiscDirty(): void;
  31176. /**
  31177. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31178. */
  31179. get scaling(): Vector3;
  31180. set scaling(newScaling: Vector3);
  31181. /**
  31182. * Returns true if the mesh is blocked. Implemented by child classes
  31183. */
  31184. get isBlocked(): boolean;
  31185. /**
  31186. * Returns the mesh itself by default. Implemented by child classes
  31187. * @param camera defines the camera to use to pick the right LOD level
  31188. * @returns the currentAbstractMesh
  31189. */
  31190. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31191. /**
  31192. * Returns 0 by default. Implemented by child classes
  31193. * @returns an integer
  31194. */
  31195. getTotalVertices(): number;
  31196. /**
  31197. * Returns a positive integer : the total number of indices in this mesh geometry.
  31198. * @returns the numner of indices or zero if the mesh has no geometry.
  31199. */
  31200. getTotalIndices(): number;
  31201. /**
  31202. * Returns null by default. Implemented by child classes
  31203. * @returns null
  31204. */
  31205. getIndices(): Nullable<IndicesArray>;
  31206. /**
  31207. * Returns the array of the requested vertex data kind. Implemented by child classes
  31208. * @param kind defines the vertex data kind to use
  31209. * @returns null
  31210. */
  31211. getVerticesData(kind: string): Nullable<FloatArray>;
  31212. /**
  31213. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31214. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31215. * Note that a new underlying VertexBuffer object is created each call.
  31216. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31217. * @param kind defines vertex data kind:
  31218. * * VertexBuffer.PositionKind
  31219. * * VertexBuffer.UVKind
  31220. * * VertexBuffer.UV2Kind
  31221. * * VertexBuffer.UV3Kind
  31222. * * VertexBuffer.UV4Kind
  31223. * * VertexBuffer.UV5Kind
  31224. * * VertexBuffer.UV6Kind
  31225. * * VertexBuffer.ColorKind
  31226. * * VertexBuffer.MatricesIndicesKind
  31227. * * VertexBuffer.MatricesIndicesExtraKind
  31228. * * VertexBuffer.MatricesWeightsKind
  31229. * * VertexBuffer.MatricesWeightsExtraKind
  31230. * @param data defines the data source
  31231. * @param updatable defines if the data must be flagged as updatable (or static)
  31232. * @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
  31233. * @returns the current mesh
  31234. */
  31235. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31236. /**
  31237. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31238. * If the mesh has no geometry, it is simply returned as it is.
  31239. * @param kind defines vertex data kind:
  31240. * * VertexBuffer.PositionKind
  31241. * * VertexBuffer.UVKind
  31242. * * VertexBuffer.UV2Kind
  31243. * * VertexBuffer.UV3Kind
  31244. * * VertexBuffer.UV4Kind
  31245. * * VertexBuffer.UV5Kind
  31246. * * VertexBuffer.UV6Kind
  31247. * * VertexBuffer.ColorKind
  31248. * * VertexBuffer.MatricesIndicesKind
  31249. * * VertexBuffer.MatricesIndicesExtraKind
  31250. * * VertexBuffer.MatricesWeightsKind
  31251. * * VertexBuffer.MatricesWeightsExtraKind
  31252. * @param data defines the data source
  31253. * @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
  31254. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31255. * @returns the current mesh
  31256. */
  31257. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31258. /**
  31259. * Sets the mesh indices,
  31260. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31261. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31262. * @param totalVertices Defines the total number of vertices
  31263. * @returns the current mesh
  31264. */
  31265. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31266. /**
  31267. * Gets a boolean indicating if specific vertex data is present
  31268. * @param kind defines the vertex data kind to use
  31269. * @returns true is data kind is present
  31270. */
  31271. isVerticesDataPresent(kind: string): boolean;
  31272. /**
  31273. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31274. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31275. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31276. * @returns a BoundingInfo
  31277. */
  31278. getBoundingInfo(): BoundingInfo;
  31279. /**
  31280. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31281. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31282. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31283. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31284. * @returns the current mesh
  31285. */
  31286. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31287. /**
  31288. * Overwrite the current bounding info
  31289. * @param boundingInfo defines the new bounding info
  31290. * @returns the current mesh
  31291. */
  31292. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31293. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31294. get useBones(): boolean;
  31295. /** @hidden */
  31296. _preActivate(): void;
  31297. /** @hidden */
  31298. _preActivateForIntermediateRendering(renderId: number): void;
  31299. /** @hidden */
  31300. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31301. /** @hidden */
  31302. _postActivate(): void;
  31303. /** @hidden */
  31304. _freeze(): void;
  31305. /** @hidden */
  31306. _unFreeze(): void;
  31307. /**
  31308. * Gets the current world matrix
  31309. * @returns a Matrix
  31310. */
  31311. getWorldMatrix(): Matrix;
  31312. /** @hidden */
  31313. _getWorldMatrixDeterminant(): number;
  31314. /**
  31315. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31316. */
  31317. get isAnInstance(): boolean;
  31318. /**
  31319. * Gets a boolean indicating if this mesh has instances
  31320. */
  31321. get hasInstances(): boolean;
  31322. /**
  31323. * Perform relative position change from the point of view of behind the front of the mesh.
  31324. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31325. * Supports definition of mesh facing forward or backward
  31326. * @param amountRight defines the distance on the right axis
  31327. * @param amountUp defines the distance on the up axis
  31328. * @param amountForward defines the distance on the forward axis
  31329. * @returns the current mesh
  31330. */
  31331. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31332. /**
  31333. * Calculate relative position change from the point of view of behind the front of the mesh.
  31334. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31335. * Supports definition of mesh facing forward or backward
  31336. * @param amountRight defines the distance on the right axis
  31337. * @param amountUp defines the distance on the up axis
  31338. * @param amountForward defines the distance on the forward axis
  31339. * @returns the new displacement vector
  31340. */
  31341. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31342. /**
  31343. * Perform 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 current mesh
  31349. */
  31350. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31351. /**
  31352. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31353. * Supports definition of mesh facing forward or backward.
  31354. * @param flipBack defines the flip
  31355. * @param twirlClockwise defines the twirl
  31356. * @param tiltRight defines the tilt
  31357. * @returns the new rotation vector
  31358. */
  31359. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31360. /**
  31361. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31362. * This means the mesh underlying bounding box and sphere are recomputed.
  31363. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31364. * @returns the current mesh
  31365. */
  31366. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31367. /** @hidden */
  31368. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31369. /** @hidden */
  31370. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31371. /** @hidden */
  31372. _updateBoundingInfo(): AbstractMesh;
  31373. /** @hidden */
  31374. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31375. /** @hidden */
  31376. protected _afterComputeWorldMatrix(): void;
  31377. /** @hidden */
  31378. get _effectiveMesh(): AbstractMesh;
  31379. /**
  31380. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31381. * A mesh is in the frustum if its bounding box intersects the frustum
  31382. * @param frustumPlanes defines the frustum to test
  31383. * @returns true if the mesh is in the frustum planes
  31384. */
  31385. isInFrustum(frustumPlanes: Plane[]): boolean;
  31386. /**
  31387. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31388. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31389. * @param frustumPlanes defines the frustum to test
  31390. * @returns true if the mesh is completely in the frustum planes
  31391. */
  31392. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31393. /**
  31394. * True if the mesh intersects another mesh or a SolidParticle object
  31395. * @param mesh defines a target mesh or SolidParticle to test
  31396. * @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)
  31397. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31398. * @returns true if there is an intersection
  31399. */
  31400. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31401. /**
  31402. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31403. * @param point defines the point to test
  31404. * @returns true if there is an intersection
  31405. */
  31406. intersectsPoint(point: Vector3): boolean;
  31407. /**
  31408. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31409. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31410. */
  31411. get checkCollisions(): boolean;
  31412. set checkCollisions(collisionEnabled: boolean);
  31413. /**
  31414. * Gets Collider object used to compute collisions (not physics)
  31415. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31416. */
  31417. get collider(): Nullable<Collider>;
  31418. /**
  31419. * Move the mesh using collision engine
  31420. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31421. * @param displacement defines the requested displacement vector
  31422. * @returns the current mesh
  31423. */
  31424. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31425. private _onCollisionPositionChange;
  31426. /** @hidden */
  31427. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31428. /** @hidden */
  31429. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31430. /** @hidden */
  31431. _checkCollision(collider: Collider): AbstractMesh;
  31432. /** @hidden */
  31433. _generatePointsArray(): boolean;
  31434. /**
  31435. * Checks if the passed Ray intersects with the mesh
  31436. * @param ray defines the ray to use
  31437. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31438. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31439. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31440. * @returns the picking info
  31441. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31442. */
  31443. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31444. /**
  31445. * Clones the current mesh
  31446. * @param name defines the mesh name
  31447. * @param newParent defines the new mesh parent
  31448. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31449. * @returns the new mesh
  31450. */
  31451. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31452. /**
  31453. * Disposes all the submeshes of the current meshnp
  31454. * @returns the current mesh
  31455. */
  31456. releaseSubMeshes(): AbstractMesh;
  31457. /**
  31458. * Releases resources associated with this abstract mesh.
  31459. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31460. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31461. */
  31462. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31463. /**
  31464. * Adds the passed mesh as a child to the current mesh
  31465. * @param mesh defines the child mesh
  31466. * @returns the current mesh
  31467. */
  31468. addChild(mesh: AbstractMesh): AbstractMesh;
  31469. /**
  31470. * Removes the passed mesh from the current mesh children list
  31471. * @param mesh defines the child mesh
  31472. * @returns the current mesh
  31473. */
  31474. removeChild(mesh: AbstractMesh): AbstractMesh;
  31475. /** @hidden */
  31476. private _initFacetData;
  31477. /**
  31478. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31479. * This method can be called within the render loop.
  31480. * 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
  31481. * @returns the current mesh
  31482. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31483. */
  31484. updateFacetData(): AbstractMesh;
  31485. /**
  31486. * Returns the facetLocalNormals array.
  31487. * The normals are expressed in the mesh local spac
  31488. * @returns an array of Vector3
  31489. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31490. */
  31491. getFacetLocalNormals(): Vector3[];
  31492. /**
  31493. * Returns the facetLocalPositions array.
  31494. * The facet positions are expressed in the mesh local space
  31495. * @returns an array of Vector3
  31496. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31497. */
  31498. getFacetLocalPositions(): Vector3[];
  31499. /**
  31500. * Returns the facetLocalPartioning array
  31501. * @returns an array of array of numbers
  31502. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31503. */
  31504. getFacetLocalPartitioning(): number[][];
  31505. /**
  31506. * Returns the i-th facet position in the world system.
  31507. * This method allocates a new Vector3 per call
  31508. * @param i defines the facet index
  31509. * @returns a new Vector3
  31510. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31511. */
  31512. getFacetPosition(i: number): Vector3;
  31513. /**
  31514. * Sets the reference Vector3 with the i-th facet position in the world system
  31515. * @param i defines the facet index
  31516. * @param ref defines the target vector
  31517. * @returns the current mesh
  31518. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31519. */
  31520. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31521. /**
  31522. * Returns the i-th facet normal in the world system.
  31523. * This method allocates a new Vector3 per call
  31524. * @param i defines the facet index
  31525. * @returns a new Vector3
  31526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31527. */
  31528. getFacetNormal(i: number): Vector3;
  31529. /**
  31530. * Sets the reference Vector3 with the i-th facet normal in the world system
  31531. * @param i defines the facet index
  31532. * @param ref defines the target vector
  31533. * @returns the current mesh
  31534. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31535. */
  31536. getFacetNormalToRef(i: number, ref: Vector3): this;
  31537. /**
  31538. * 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)
  31539. * @param x defines x coordinate
  31540. * @param y defines y coordinate
  31541. * @param z defines z coordinate
  31542. * @returns the array of facet indexes
  31543. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31544. */
  31545. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31546. /**
  31547. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31548. * @param projected sets as the (x,y,z) world projection on the facet
  31549. * @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
  31550. * @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
  31551. * @param x defines x coordinate
  31552. * @param y defines y coordinate
  31553. * @param z defines z coordinate
  31554. * @returns the face index if found (or null instead)
  31555. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31556. */
  31557. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31558. /**
  31559. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31560. * @param projected sets as the (x,y,z) local projection on the facet
  31561. * @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
  31562. * @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
  31563. * @param x defines x coordinate
  31564. * @param y defines y coordinate
  31565. * @param z defines z coordinate
  31566. * @returns the face index if found (or null instead)
  31567. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31568. */
  31569. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31570. /**
  31571. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31572. * @returns the parameters
  31573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31574. */
  31575. getFacetDataParameters(): any;
  31576. /**
  31577. * Disables the feature FacetData and frees the related memory
  31578. * @returns the current mesh
  31579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31580. */
  31581. disableFacetData(): AbstractMesh;
  31582. /**
  31583. * Updates the AbstractMesh indices array
  31584. * @param indices defines the data source
  31585. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31586. * @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)
  31587. * @returns the current mesh
  31588. */
  31589. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31590. /**
  31591. * Creates new normals data for the mesh
  31592. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31593. * @returns the current mesh
  31594. */
  31595. createNormals(updatable: boolean): AbstractMesh;
  31596. /**
  31597. * Align the mesh with a normal
  31598. * @param normal defines the normal to use
  31599. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31600. * @returns the current mesh
  31601. */
  31602. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31603. /** @hidden */
  31604. _checkOcclusionQuery(): boolean;
  31605. /**
  31606. * Disables the mesh edge rendering mode
  31607. * @returns the currentAbstractMesh
  31608. */
  31609. disableEdgesRendering(): AbstractMesh;
  31610. /**
  31611. * Enables the edge rendering mode on the mesh.
  31612. * This mode makes the mesh edges visible
  31613. * @param epsilon defines the maximal distance between two angles to detect a face
  31614. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31615. * @returns the currentAbstractMesh
  31616. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31617. */
  31618. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31619. }
  31620. }
  31621. declare module BABYLON {
  31622. /**
  31623. * Interface used to define ActionEvent
  31624. */
  31625. export interface IActionEvent {
  31626. /** The mesh or sprite that triggered the action */
  31627. source: any;
  31628. /** The X mouse cursor position at the time of the event */
  31629. pointerX: number;
  31630. /** The Y mouse cursor position at the time of the event */
  31631. pointerY: number;
  31632. /** The mesh that is currently pointed at (can be null) */
  31633. meshUnderPointer: Nullable<AbstractMesh>;
  31634. /** the original (browser) event that triggered the ActionEvent */
  31635. sourceEvent?: any;
  31636. /** additional data for the event */
  31637. additionalData?: any;
  31638. }
  31639. /**
  31640. * ActionEvent is the event being sent when an action is triggered.
  31641. */
  31642. export class ActionEvent implements IActionEvent {
  31643. /** The mesh or sprite that triggered the action */
  31644. source: any;
  31645. /** The X mouse cursor position at the time of the event */
  31646. pointerX: number;
  31647. /** The Y mouse cursor position at the time of the event */
  31648. pointerY: number;
  31649. /** The mesh that is currently pointed at (can be null) */
  31650. meshUnderPointer: Nullable<AbstractMesh>;
  31651. /** the original (browser) event that triggered the ActionEvent */
  31652. sourceEvent?: any;
  31653. /** additional data for the event */
  31654. additionalData?: any;
  31655. /**
  31656. * Creates a new ActionEvent
  31657. * @param source The mesh or sprite that triggered the action
  31658. * @param pointerX The X mouse cursor position at the time of the event
  31659. * @param pointerY The Y mouse cursor position at the time of the event
  31660. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31661. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31662. * @param additionalData additional data for the event
  31663. */
  31664. constructor(
  31665. /** The mesh or sprite that triggered the action */
  31666. source: any,
  31667. /** The X mouse cursor position at the time of the event */
  31668. pointerX: number,
  31669. /** The Y mouse cursor position at the time of the event */
  31670. pointerY: number,
  31671. /** The mesh that is currently pointed at (can be null) */
  31672. meshUnderPointer: Nullable<AbstractMesh>,
  31673. /** the original (browser) event that triggered the ActionEvent */
  31674. sourceEvent?: any,
  31675. /** additional data for the event */
  31676. additionalData?: any);
  31677. /**
  31678. * Helper function to auto-create an ActionEvent from a source mesh.
  31679. * @param source The source mesh that triggered the event
  31680. * @param evt The original (browser) event
  31681. * @param additionalData additional data for the event
  31682. * @returns the new ActionEvent
  31683. */
  31684. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31685. /**
  31686. * Helper function to auto-create an ActionEvent from a source sprite
  31687. * @param source The source sprite that triggered the event
  31688. * @param scene Scene associated with the sprite
  31689. * @param evt The original (browser) event
  31690. * @param additionalData additional data for the event
  31691. * @returns the new ActionEvent
  31692. */
  31693. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31694. /**
  31695. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31696. * @param scene the scene where the event occurred
  31697. * @param evt The original (browser) event
  31698. * @returns the new ActionEvent
  31699. */
  31700. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31701. /**
  31702. * Helper function to auto-create an ActionEvent from a primitive
  31703. * @param prim defines the target primitive
  31704. * @param pointerPos defines the pointer position
  31705. * @param evt The original (browser) event
  31706. * @param additionalData additional data for the event
  31707. * @returns the new ActionEvent
  31708. */
  31709. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31710. }
  31711. }
  31712. declare module BABYLON {
  31713. /**
  31714. * Abstract class used to decouple action Manager from scene and meshes.
  31715. * Do not instantiate.
  31716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31717. */
  31718. export abstract class AbstractActionManager implements IDisposable {
  31719. /** Gets the list of active triggers */
  31720. static Triggers: {
  31721. [key: string]: number;
  31722. };
  31723. /** Gets the cursor to use when hovering items */
  31724. hoverCursor: string;
  31725. /** Gets the list of actions */
  31726. actions: IAction[];
  31727. /**
  31728. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31729. */
  31730. isRecursive: boolean;
  31731. /**
  31732. * Releases all associated resources
  31733. */
  31734. abstract dispose(): void;
  31735. /**
  31736. * Does this action manager has pointer triggers
  31737. */
  31738. abstract get hasPointerTriggers(): boolean;
  31739. /**
  31740. * Does this action manager has pick triggers
  31741. */
  31742. abstract get hasPickTriggers(): boolean;
  31743. /**
  31744. * Process a specific trigger
  31745. * @param trigger defines the trigger to process
  31746. * @param evt defines the event details to be processed
  31747. */
  31748. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31749. /**
  31750. * Does this action manager handles actions of any of the given triggers
  31751. * @param triggers defines the triggers to be tested
  31752. * @return a boolean indicating whether one (or more) of the triggers is handled
  31753. */
  31754. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31755. /**
  31756. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31757. * speed.
  31758. * @param triggerA defines the trigger to be tested
  31759. * @param triggerB defines the trigger to be tested
  31760. * @return a boolean indicating whether one (or more) of the triggers is handled
  31761. */
  31762. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31763. /**
  31764. * Does this action manager handles actions of a given trigger
  31765. * @param trigger defines the trigger to be tested
  31766. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31767. * @return whether the trigger is handled
  31768. */
  31769. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31770. /**
  31771. * Serialize this manager to a JSON object
  31772. * @param name defines the property name to store this manager
  31773. * @returns a JSON representation of this manager
  31774. */
  31775. abstract serialize(name: string): any;
  31776. /**
  31777. * Registers an action to this action manager
  31778. * @param action defines the action to be registered
  31779. * @return the action amended (prepared) after registration
  31780. */
  31781. abstract registerAction(action: IAction): Nullable<IAction>;
  31782. /**
  31783. * Unregisters an action to this action manager
  31784. * @param action defines the action to be unregistered
  31785. * @return a boolean indicating whether the action has been unregistered
  31786. */
  31787. abstract unregisterAction(action: IAction): Boolean;
  31788. /**
  31789. * Does exist one action manager with at least one trigger
  31790. **/
  31791. static get HasTriggers(): boolean;
  31792. /**
  31793. * Does exist one action manager with at least one pick trigger
  31794. **/
  31795. static get HasPickTriggers(): boolean;
  31796. /**
  31797. * Does exist one action manager that handles actions of a given trigger
  31798. * @param trigger defines the trigger to be tested
  31799. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31800. **/
  31801. static HasSpecificTrigger(trigger: number): boolean;
  31802. }
  31803. }
  31804. declare module BABYLON {
  31805. /**
  31806. * Defines how a node can be built from a string name.
  31807. */
  31808. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31809. /**
  31810. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31811. */
  31812. export class Node implements IBehaviorAware<Node> {
  31813. /** @hidden */
  31814. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31815. private static _NodeConstructors;
  31816. /**
  31817. * Add a new node constructor
  31818. * @param type defines the type name of the node to construct
  31819. * @param constructorFunc defines the constructor function
  31820. */
  31821. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31822. /**
  31823. * Returns a node constructor based on type name
  31824. * @param type defines the type name
  31825. * @param name defines the new node name
  31826. * @param scene defines the hosting scene
  31827. * @param options defines optional options to transmit to constructors
  31828. * @returns the new constructor or null
  31829. */
  31830. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31831. /**
  31832. * Gets or sets the name of the node
  31833. */
  31834. name: string;
  31835. /**
  31836. * Gets or sets the id of the node
  31837. */
  31838. id: string;
  31839. /**
  31840. * Gets or sets the unique id of the node
  31841. */
  31842. uniqueId: number;
  31843. /**
  31844. * Gets or sets a string used to store user defined state for the node
  31845. */
  31846. state: string;
  31847. /**
  31848. * Gets or sets an object used to store user defined information for the node
  31849. */
  31850. metadata: any;
  31851. /**
  31852. * For internal use only. Please do not use.
  31853. */
  31854. reservedDataStore: any;
  31855. /**
  31856. * List of inspectable custom properties (used by the Inspector)
  31857. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31858. */
  31859. inspectableCustomProperties: IInspectable[];
  31860. private _doNotSerialize;
  31861. /**
  31862. * Gets or sets a boolean used to define if the node must be serialized
  31863. */
  31864. get doNotSerialize(): boolean;
  31865. set doNotSerialize(value: boolean);
  31866. /** @hidden */
  31867. _isDisposed: boolean;
  31868. /**
  31869. * Gets a list of Animations associated with the node
  31870. */
  31871. animations: Animation[];
  31872. protected _ranges: {
  31873. [name: string]: Nullable<AnimationRange>;
  31874. };
  31875. /**
  31876. * Callback raised when the node is ready to be used
  31877. */
  31878. onReady: Nullable<(node: Node) => void>;
  31879. private _isEnabled;
  31880. private _isParentEnabled;
  31881. private _isReady;
  31882. /** @hidden */
  31883. _currentRenderId: number;
  31884. private _parentUpdateId;
  31885. /** @hidden */
  31886. _childUpdateId: number;
  31887. /** @hidden */
  31888. _waitingParentId: Nullable<string>;
  31889. /** @hidden */
  31890. _scene: Scene;
  31891. /** @hidden */
  31892. _cache: any;
  31893. private _parentNode;
  31894. private _children;
  31895. /** @hidden */
  31896. _worldMatrix: Matrix;
  31897. /** @hidden */
  31898. _worldMatrixDeterminant: number;
  31899. /** @hidden */
  31900. _worldMatrixDeterminantIsDirty: boolean;
  31901. /** @hidden */
  31902. private _sceneRootNodesIndex;
  31903. /**
  31904. * Gets a boolean indicating if the node has been disposed
  31905. * @returns true if the node was disposed
  31906. */
  31907. isDisposed(): boolean;
  31908. /**
  31909. * Gets or sets the parent of the node (without keeping the current position in the scene)
  31910. * @see https://doc.babylonjs.com/how_to/parenting
  31911. */
  31912. set parent(parent: Nullable<Node>);
  31913. get parent(): Nullable<Node>;
  31914. /** @hidden */
  31915. _addToSceneRootNodes(): void;
  31916. /** @hidden */
  31917. _removeFromSceneRootNodes(): void;
  31918. private _animationPropertiesOverride;
  31919. /**
  31920. * Gets or sets the animation properties override
  31921. */
  31922. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31923. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31924. /**
  31925. * Gets a string idenfifying the name of the class
  31926. * @returns "Node" string
  31927. */
  31928. getClassName(): string;
  31929. /** @hidden */
  31930. readonly _isNode: boolean;
  31931. /**
  31932. * An event triggered when the mesh is disposed
  31933. */
  31934. onDisposeObservable: Observable<Node>;
  31935. private _onDisposeObserver;
  31936. /**
  31937. * Sets a callback that will be raised when the node will be disposed
  31938. */
  31939. set onDispose(callback: () => void);
  31940. /**
  31941. * Creates a new Node
  31942. * @param name the name and id to be given to this node
  31943. * @param scene the scene this node will be added to
  31944. */
  31945. constructor(name: string, scene?: Nullable<Scene>);
  31946. /**
  31947. * Gets the scene of the node
  31948. * @returns a scene
  31949. */
  31950. getScene(): Scene;
  31951. /**
  31952. * Gets the engine of the node
  31953. * @returns a Engine
  31954. */
  31955. getEngine(): Engine;
  31956. private _behaviors;
  31957. /**
  31958. * Attach a behavior to the node
  31959. * @see http://doc.babylonjs.com/features/behaviour
  31960. * @param behavior defines the behavior to attach
  31961. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  31962. * @returns the current Node
  31963. */
  31964. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  31965. /**
  31966. * Remove an attached behavior
  31967. * @see http://doc.babylonjs.com/features/behaviour
  31968. * @param behavior defines the behavior to attach
  31969. * @returns the current Node
  31970. */
  31971. removeBehavior(behavior: Behavior<Node>): Node;
  31972. /**
  31973. * Gets the list of attached behaviors
  31974. * @see http://doc.babylonjs.com/features/behaviour
  31975. */
  31976. get behaviors(): Behavior<Node>[];
  31977. /**
  31978. * Gets an attached behavior by name
  31979. * @param name defines the name of the behavior to look for
  31980. * @see http://doc.babylonjs.com/features/behaviour
  31981. * @returns null if behavior was not found else the requested behavior
  31982. */
  31983. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  31984. /**
  31985. * Returns the latest update of the World matrix
  31986. * @returns a Matrix
  31987. */
  31988. getWorldMatrix(): Matrix;
  31989. /** @hidden */
  31990. _getWorldMatrixDeterminant(): number;
  31991. /**
  31992. * Returns directly the latest state of the mesh World matrix.
  31993. * A Matrix is returned.
  31994. */
  31995. get worldMatrixFromCache(): Matrix;
  31996. /** @hidden */
  31997. _initCache(): void;
  31998. /** @hidden */
  31999. updateCache(force?: boolean): void;
  32000. /** @hidden */
  32001. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32002. /** @hidden */
  32003. _updateCache(ignoreParentClass?: boolean): void;
  32004. /** @hidden */
  32005. _isSynchronized(): boolean;
  32006. /** @hidden */
  32007. _markSyncedWithParent(): void;
  32008. /** @hidden */
  32009. isSynchronizedWithParent(): boolean;
  32010. /** @hidden */
  32011. isSynchronized(): boolean;
  32012. /**
  32013. * Is this node ready to be used/rendered
  32014. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32015. * @return true if the node is ready
  32016. */
  32017. isReady(completeCheck?: boolean): boolean;
  32018. /**
  32019. * Is this node enabled?
  32020. * 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
  32021. * @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
  32022. * @return whether this node (and its parent) is enabled
  32023. */
  32024. isEnabled(checkAncestors?: boolean): boolean;
  32025. /** @hidden */
  32026. protected _syncParentEnabledState(): void;
  32027. /**
  32028. * Set the enabled state of this node
  32029. * @param value defines the new enabled state
  32030. */
  32031. setEnabled(value: boolean): void;
  32032. /**
  32033. * Is this node a descendant of the given node?
  32034. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32035. * @param ancestor defines the parent node to inspect
  32036. * @returns a boolean indicating if this node is a descendant of the given node
  32037. */
  32038. isDescendantOf(ancestor: Node): boolean;
  32039. /** @hidden */
  32040. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32041. /**
  32042. * Will return all nodes that have this node as ascendant
  32043. * @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
  32044. * @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
  32045. * @return all children nodes of all types
  32046. */
  32047. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32048. /**
  32049. * Get all child-meshes of this node
  32050. * @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)
  32051. * @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
  32052. * @returns an array of AbstractMesh
  32053. */
  32054. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32055. /**
  32056. * Get all direct children of this node
  32057. * @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
  32058. * @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)
  32059. * @returns an array of Node
  32060. */
  32061. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32062. /** @hidden */
  32063. _setReady(state: boolean): void;
  32064. /**
  32065. * Get an animation by name
  32066. * @param name defines the name of the animation to look for
  32067. * @returns null if not found else the requested animation
  32068. */
  32069. getAnimationByName(name: string): Nullable<Animation>;
  32070. /**
  32071. * Creates an animation range for this node
  32072. * @param name defines the name of the range
  32073. * @param from defines the starting key
  32074. * @param to defines the end key
  32075. */
  32076. createAnimationRange(name: string, from: number, to: number): void;
  32077. /**
  32078. * Delete a specific animation range
  32079. * @param name defines the name of the range to delete
  32080. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32081. */
  32082. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32083. /**
  32084. * Get an animation range by name
  32085. * @param name defines the name of the animation range to look for
  32086. * @returns null if not found else the requested animation range
  32087. */
  32088. getAnimationRange(name: string): Nullable<AnimationRange>;
  32089. /**
  32090. * Gets the list of all animation ranges defined on this node
  32091. * @returns an array
  32092. */
  32093. getAnimationRanges(): Nullable<AnimationRange>[];
  32094. /**
  32095. * Will start the animation sequence
  32096. * @param name defines the range frames for animation sequence
  32097. * @param loop defines if the animation should loop (false by default)
  32098. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32099. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32100. * @returns the object created for this animation. If range does not exist, it will return null
  32101. */
  32102. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32103. /**
  32104. * Serialize animation ranges into a JSON compatible object
  32105. * @returns serialization object
  32106. */
  32107. serializeAnimationRanges(): any;
  32108. /**
  32109. * Computes the world matrix of the node
  32110. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32111. * @returns the world matrix
  32112. */
  32113. computeWorldMatrix(force?: boolean): Matrix;
  32114. /**
  32115. * Releases resources associated with this node.
  32116. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32117. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32118. */
  32119. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32120. /**
  32121. * Parse animation range data from a serialization object and store them into a given node
  32122. * @param node defines where to store the animation ranges
  32123. * @param parsedNode defines the serialization object to read data from
  32124. * @param scene defines the hosting scene
  32125. */
  32126. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32127. /**
  32128. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32129. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32130. * @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
  32131. * @returns the new bounding vectors
  32132. */
  32133. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32134. min: Vector3;
  32135. max: Vector3;
  32136. };
  32137. }
  32138. }
  32139. declare module BABYLON {
  32140. /**
  32141. * @hidden
  32142. */
  32143. export class _IAnimationState {
  32144. key: number;
  32145. repeatCount: number;
  32146. workValue?: any;
  32147. loopMode?: number;
  32148. offsetValue?: any;
  32149. highLimitValue?: any;
  32150. }
  32151. /**
  32152. * Class used to store any kind of animation
  32153. */
  32154. export class Animation {
  32155. /**Name of the animation */
  32156. name: string;
  32157. /**Property to animate */
  32158. targetProperty: string;
  32159. /**The frames per second of the animation */
  32160. framePerSecond: number;
  32161. /**The data type of the animation */
  32162. dataType: number;
  32163. /**The loop mode of the animation */
  32164. loopMode?: number | undefined;
  32165. /**Specifies if blending should be enabled */
  32166. enableBlending?: boolean | undefined;
  32167. /**
  32168. * Use matrix interpolation instead of using direct key value when animating matrices
  32169. */
  32170. static AllowMatricesInterpolation: boolean;
  32171. /**
  32172. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32173. */
  32174. static AllowMatrixDecomposeForInterpolation: boolean;
  32175. /**
  32176. * Stores the key frames of the animation
  32177. */
  32178. private _keys;
  32179. /**
  32180. * Stores the easing function of the animation
  32181. */
  32182. private _easingFunction;
  32183. /**
  32184. * @hidden Internal use only
  32185. */
  32186. _runtimeAnimations: RuntimeAnimation[];
  32187. /**
  32188. * The set of event that will be linked to this animation
  32189. */
  32190. private _events;
  32191. /**
  32192. * Stores an array of target property paths
  32193. */
  32194. targetPropertyPath: string[];
  32195. /**
  32196. * Stores the blending speed of the animation
  32197. */
  32198. blendingSpeed: number;
  32199. /**
  32200. * Stores the animation ranges for the animation
  32201. */
  32202. private _ranges;
  32203. /**
  32204. * @hidden Internal use
  32205. */
  32206. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32207. /**
  32208. * Sets up an animation
  32209. * @param property The property to animate
  32210. * @param animationType The animation type to apply
  32211. * @param framePerSecond The frames per second of the animation
  32212. * @param easingFunction The easing function used in the animation
  32213. * @returns The created animation
  32214. */
  32215. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32216. /**
  32217. * Create and start an animation on a node
  32218. * @param name defines the name of the global animation that will be run on all nodes
  32219. * @param node defines the root node where the animation will take place
  32220. * @param targetProperty defines property to animate
  32221. * @param framePerSecond defines the number of frame per second yo use
  32222. * @param totalFrame defines the number of frames in total
  32223. * @param from defines the initial value
  32224. * @param to defines the final value
  32225. * @param loopMode defines which loop mode you want to use (off by default)
  32226. * @param easingFunction defines the easing function to use (linear by default)
  32227. * @param onAnimationEnd defines the callback to call when animation end
  32228. * @returns the animatable created for this animation
  32229. */
  32230. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32231. /**
  32232. * Create and start an animation on a node and its descendants
  32233. * @param name defines the name of the global animation that will be run on all nodes
  32234. * @param node defines the root node where the animation will take place
  32235. * @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
  32236. * @param targetProperty defines property to animate
  32237. * @param framePerSecond defines the number of frame per second to use
  32238. * @param totalFrame defines the number of frames in total
  32239. * @param from defines the initial value
  32240. * @param to defines the final value
  32241. * @param loopMode defines which loop mode you want to use (off by default)
  32242. * @param easingFunction defines the easing function to use (linear by default)
  32243. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32244. * @returns the list of animatables created for all nodes
  32245. * @example https://www.babylonjs-playground.com/#MH0VLI
  32246. */
  32247. 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[]>;
  32248. /**
  32249. * Creates a new animation, merges it with the existing animations and starts it
  32250. * @param name Name of the animation
  32251. * @param node Node which contains the scene that begins the animations
  32252. * @param targetProperty Specifies which property to animate
  32253. * @param framePerSecond The frames per second of the animation
  32254. * @param totalFrame The total number of frames
  32255. * @param from The frame at the beginning of the animation
  32256. * @param to The frame at the end of the animation
  32257. * @param loopMode Specifies the loop mode of the animation
  32258. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32259. * @param onAnimationEnd Callback to run once the animation is complete
  32260. * @returns Nullable animation
  32261. */
  32262. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32263. /**
  32264. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32265. * @param sourceAnimation defines the Animation containing keyframes to convert
  32266. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32267. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32268. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32269. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32270. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32271. */
  32272. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32273. /**
  32274. * Transition property of an host to the target Value
  32275. * @param property The property to transition
  32276. * @param targetValue The target Value of the property
  32277. * @param host The object where the property to animate belongs
  32278. * @param scene Scene used to run the animation
  32279. * @param frameRate Framerate (in frame/s) to use
  32280. * @param transition The transition type we want to use
  32281. * @param duration The duration of the animation, in milliseconds
  32282. * @param onAnimationEnd Callback trigger at the end of the animation
  32283. * @returns Nullable animation
  32284. */
  32285. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32286. /**
  32287. * Return the array of runtime animations currently using this animation
  32288. */
  32289. get runtimeAnimations(): RuntimeAnimation[];
  32290. /**
  32291. * Specifies if any of the runtime animations are currently running
  32292. */
  32293. get hasRunningRuntimeAnimations(): boolean;
  32294. /**
  32295. * Initializes the animation
  32296. * @param name Name of the animation
  32297. * @param targetProperty Property to animate
  32298. * @param framePerSecond The frames per second of the animation
  32299. * @param dataType The data type of the animation
  32300. * @param loopMode The loop mode of the animation
  32301. * @param enableBlending Specifies if blending should be enabled
  32302. */
  32303. constructor(
  32304. /**Name of the animation */
  32305. name: string,
  32306. /**Property to animate */
  32307. targetProperty: string,
  32308. /**The frames per second of the animation */
  32309. framePerSecond: number,
  32310. /**The data type of the animation */
  32311. dataType: number,
  32312. /**The loop mode of the animation */
  32313. loopMode?: number | undefined,
  32314. /**Specifies if blending should be enabled */
  32315. enableBlending?: boolean | undefined);
  32316. /**
  32317. * Converts the animation to a string
  32318. * @param fullDetails support for multiple levels of logging within scene loading
  32319. * @returns String form of the animation
  32320. */
  32321. toString(fullDetails?: boolean): string;
  32322. /**
  32323. * Add an event to this animation
  32324. * @param event Event to add
  32325. */
  32326. addEvent(event: AnimationEvent): void;
  32327. /**
  32328. * Remove all events found at the given frame
  32329. * @param frame The frame to remove events from
  32330. */
  32331. removeEvents(frame: number): void;
  32332. /**
  32333. * Retrieves all the events from the animation
  32334. * @returns Events from the animation
  32335. */
  32336. getEvents(): AnimationEvent[];
  32337. /**
  32338. * Creates an animation range
  32339. * @param name Name of the animation range
  32340. * @param from Starting frame of the animation range
  32341. * @param to Ending frame of the animation
  32342. */
  32343. createRange(name: string, from: number, to: number): void;
  32344. /**
  32345. * Deletes an animation range by name
  32346. * @param name Name of the animation range to delete
  32347. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32348. */
  32349. deleteRange(name: string, deleteFrames?: boolean): void;
  32350. /**
  32351. * Gets the animation range by name, or null if not defined
  32352. * @param name Name of the animation range
  32353. * @returns Nullable animation range
  32354. */
  32355. getRange(name: string): Nullable<AnimationRange>;
  32356. /**
  32357. * Gets the key frames from the animation
  32358. * @returns The key frames of the animation
  32359. */
  32360. getKeys(): Array<IAnimationKey>;
  32361. /**
  32362. * Gets the highest frame rate of the animation
  32363. * @returns Highest frame rate of the animation
  32364. */
  32365. getHighestFrame(): number;
  32366. /**
  32367. * Gets the easing function of the animation
  32368. * @returns Easing function of the animation
  32369. */
  32370. getEasingFunction(): IEasingFunction;
  32371. /**
  32372. * Sets the easing function of the animation
  32373. * @param easingFunction A custom mathematical formula for animation
  32374. */
  32375. setEasingFunction(easingFunction: EasingFunction): void;
  32376. /**
  32377. * Interpolates a scalar linearly
  32378. * @param startValue Start value of the animation curve
  32379. * @param endValue End value of the animation curve
  32380. * @param gradient Scalar amount to interpolate
  32381. * @returns Interpolated scalar value
  32382. */
  32383. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32384. /**
  32385. * Interpolates a scalar cubically
  32386. * @param startValue Start value of the animation curve
  32387. * @param outTangent End tangent of the animation
  32388. * @param endValue End value of the animation curve
  32389. * @param inTangent Start tangent of the animation curve
  32390. * @param gradient Scalar amount to interpolate
  32391. * @returns Interpolated scalar value
  32392. */
  32393. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32394. /**
  32395. * Interpolates a quaternion using a spherical linear interpolation
  32396. * @param startValue Start value of the animation curve
  32397. * @param endValue End value of the animation curve
  32398. * @param gradient Scalar amount to interpolate
  32399. * @returns Interpolated quaternion value
  32400. */
  32401. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32402. /**
  32403. * Interpolates a quaternion cubically
  32404. * @param startValue Start value of the animation curve
  32405. * @param outTangent End tangent of the animation curve
  32406. * @param endValue End value of the animation curve
  32407. * @param inTangent Start tangent of the animation curve
  32408. * @param gradient Scalar amount to interpolate
  32409. * @returns Interpolated quaternion value
  32410. */
  32411. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32412. /**
  32413. * Interpolates a Vector3 linearl
  32414. * @param startValue Start value of the animation curve
  32415. * @param endValue End value of the animation curve
  32416. * @param gradient Scalar amount to interpolate
  32417. * @returns Interpolated scalar value
  32418. */
  32419. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32420. /**
  32421. * Interpolates a Vector3 cubically
  32422. * @param startValue Start value of the animation curve
  32423. * @param outTangent End tangent of the animation
  32424. * @param endValue End value of the animation curve
  32425. * @param inTangent Start tangent of the animation curve
  32426. * @param gradient Scalar amount to interpolate
  32427. * @returns InterpolatedVector3 value
  32428. */
  32429. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32430. /**
  32431. * Interpolates a Vector2 linearly
  32432. * @param startValue Start value of the animation curve
  32433. * @param endValue End value of the animation curve
  32434. * @param gradient Scalar amount to interpolate
  32435. * @returns Interpolated Vector2 value
  32436. */
  32437. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32438. /**
  32439. * Interpolates a Vector2 cubically
  32440. * @param startValue Start value of the animation curve
  32441. * @param outTangent End tangent of the animation
  32442. * @param endValue End value of the animation curve
  32443. * @param inTangent Start tangent of the animation curve
  32444. * @param gradient Scalar amount to interpolate
  32445. * @returns Interpolated Vector2 value
  32446. */
  32447. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32448. /**
  32449. * Interpolates a size linearly
  32450. * @param startValue Start value of the animation curve
  32451. * @param endValue End value of the animation curve
  32452. * @param gradient Scalar amount to interpolate
  32453. * @returns Interpolated Size value
  32454. */
  32455. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32456. /**
  32457. * Interpolates a Color3 linearly
  32458. * @param startValue Start value of the animation curve
  32459. * @param endValue End value of the animation curve
  32460. * @param gradient Scalar amount to interpolate
  32461. * @returns Interpolated Color3 value
  32462. */
  32463. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32464. /**
  32465. * Interpolates a Color4 linearly
  32466. * @param startValue Start value of the animation curve
  32467. * @param endValue End value of the animation curve
  32468. * @param gradient Scalar amount to interpolate
  32469. * @returns Interpolated Color3 value
  32470. */
  32471. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32472. /**
  32473. * @hidden Internal use only
  32474. */
  32475. _getKeyValue(value: any): any;
  32476. /**
  32477. * @hidden Internal use only
  32478. */
  32479. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32480. /**
  32481. * Defines the function to use to interpolate matrices
  32482. * @param startValue defines the start matrix
  32483. * @param endValue defines the end matrix
  32484. * @param gradient defines the gradient between both matrices
  32485. * @param result defines an optional target matrix where to store the interpolation
  32486. * @returns the interpolated matrix
  32487. */
  32488. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32489. /**
  32490. * Makes a copy of the animation
  32491. * @returns Cloned animation
  32492. */
  32493. clone(): Animation;
  32494. /**
  32495. * Sets the key frames of the animation
  32496. * @param values The animation key frames to set
  32497. */
  32498. setKeys(values: Array<IAnimationKey>): void;
  32499. /**
  32500. * Serializes the animation to an object
  32501. * @returns Serialized object
  32502. */
  32503. serialize(): any;
  32504. /**
  32505. * Float animation type
  32506. */
  32507. static readonly ANIMATIONTYPE_FLOAT: number;
  32508. /**
  32509. * Vector3 animation type
  32510. */
  32511. static readonly ANIMATIONTYPE_VECTOR3: number;
  32512. /**
  32513. * Quaternion animation type
  32514. */
  32515. static readonly ANIMATIONTYPE_QUATERNION: number;
  32516. /**
  32517. * Matrix animation type
  32518. */
  32519. static readonly ANIMATIONTYPE_MATRIX: number;
  32520. /**
  32521. * Color3 animation type
  32522. */
  32523. static readonly ANIMATIONTYPE_COLOR3: number;
  32524. /**
  32525. * Color3 animation type
  32526. */
  32527. static readonly ANIMATIONTYPE_COLOR4: number;
  32528. /**
  32529. * Vector2 animation type
  32530. */
  32531. static readonly ANIMATIONTYPE_VECTOR2: number;
  32532. /**
  32533. * Size animation type
  32534. */
  32535. static readonly ANIMATIONTYPE_SIZE: number;
  32536. /**
  32537. * Relative Loop Mode
  32538. */
  32539. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32540. /**
  32541. * Cycle Loop Mode
  32542. */
  32543. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32544. /**
  32545. * Constant Loop Mode
  32546. */
  32547. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32548. /** @hidden */
  32549. static _UniversalLerp(left: any, right: any, amount: number): any;
  32550. /**
  32551. * Parses an animation object and creates an animation
  32552. * @param parsedAnimation Parsed animation object
  32553. * @returns Animation object
  32554. */
  32555. static Parse(parsedAnimation: any): Animation;
  32556. /**
  32557. * Appends the serialized animations from the source animations
  32558. * @param source Source containing the animations
  32559. * @param destination Target to store the animations
  32560. */
  32561. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32562. }
  32563. }
  32564. declare module BABYLON {
  32565. /**
  32566. * Interface containing an array of animations
  32567. */
  32568. export interface IAnimatable {
  32569. /**
  32570. * Array of animations
  32571. */
  32572. animations: Nullable<Array<Animation>>;
  32573. }
  32574. }
  32575. declare module BABYLON {
  32576. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32577. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32578. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32579. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32580. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32581. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32582. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32583. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32584. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32585. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32586. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32587. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32588. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32589. /**
  32590. * Decorator used to define property that can be serialized as reference to a camera
  32591. * @param sourceName defines the name of the property to decorate
  32592. */
  32593. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32594. /**
  32595. * Class used to help serialization objects
  32596. */
  32597. export class SerializationHelper {
  32598. /** @hidden */
  32599. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32600. /** @hidden */
  32601. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32602. /** @hidden */
  32603. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32604. /** @hidden */
  32605. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32606. /**
  32607. * Appends the serialized animations from the source animations
  32608. * @param source Source containing the animations
  32609. * @param destination Target to store the animations
  32610. */
  32611. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32612. /**
  32613. * Static function used to serialized a specific entity
  32614. * @param entity defines the entity to serialize
  32615. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32616. * @returns a JSON compatible object representing the serialization of the entity
  32617. */
  32618. static Serialize<T>(entity: T, serializationObject?: any): any;
  32619. /**
  32620. * Creates a new entity from a serialization data object
  32621. * @param creationFunction defines a function used to instanciated the new entity
  32622. * @param source defines the source serialization data
  32623. * @param scene defines the hosting scene
  32624. * @param rootUrl defines the root url for resources
  32625. * @returns a new entity
  32626. */
  32627. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32628. /**
  32629. * Clones an object
  32630. * @param creationFunction defines the function used to instanciate the new object
  32631. * @param source defines the source object
  32632. * @returns the cloned object
  32633. */
  32634. static Clone<T>(creationFunction: () => T, source: T): T;
  32635. /**
  32636. * Instanciates a new object based on a source one (some data will be shared between both object)
  32637. * @param creationFunction defines the function used to instanciate the new object
  32638. * @param source defines the source object
  32639. * @returns the new object
  32640. */
  32641. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32642. }
  32643. }
  32644. declare module BABYLON {
  32645. /**
  32646. * Base class of all the textures in babylon.
  32647. * It groups all the common properties the materials, post process, lights... might need
  32648. * in order to make a correct use of the texture.
  32649. */
  32650. export class BaseTexture implements IAnimatable {
  32651. /**
  32652. * Default anisotropic filtering level for the application.
  32653. * It is set to 4 as a good tradeoff between perf and quality.
  32654. */
  32655. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32656. /**
  32657. * Gets or sets the unique id of the texture
  32658. */
  32659. uniqueId: number;
  32660. /**
  32661. * Define the name of the texture.
  32662. */
  32663. name: string;
  32664. /**
  32665. * Gets or sets an object used to store user defined information.
  32666. */
  32667. metadata: any;
  32668. /**
  32669. * For internal use only. Please do not use.
  32670. */
  32671. reservedDataStore: any;
  32672. private _hasAlpha;
  32673. /**
  32674. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32675. */
  32676. set hasAlpha(value: boolean);
  32677. get hasAlpha(): boolean;
  32678. /**
  32679. * Defines if the alpha value should be determined via the rgb values.
  32680. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32681. */
  32682. getAlphaFromRGB: boolean;
  32683. /**
  32684. * Intensity or strength of the texture.
  32685. * It is commonly used by materials to fine tune the intensity of the texture
  32686. */
  32687. level: number;
  32688. /**
  32689. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32690. * This is part of the texture as textures usually maps to one uv set.
  32691. */
  32692. coordinatesIndex: number;
  32693. private _coordinatesMode;
  32694. /**
  32695. * How a texture is mapped.
  32696. *
  32697. * | Value | Type | Description |
  32698. * | ----- | ----------------------------------- | ----------- |
  32699. * | 0 | EXPLICIT_MODE | |
  32700. * | 1 | SPHERICAL_MODE | |
  32701. * | 2 | PLANAR_MODE | |
  32702. * | 3 | CUBIC_MODE | |
  32703. * | 4 | PROJECTION_MODE | |
  32704. * | 5 | SKYBOX_MODE | |
  32705. * | 6 | INVCUBIC_MODE | |
  32706. * | 7 | EQUIRECTANGULAR_MODE | |
  32707. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32708. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32709. */
  32710. set coordinatesMode(value: number);
  32711. get coordinatesMode(): number;
  32712. /**
  32713. * | Value | Type | Description |
  32714. * | ----- | ------------------ | ----------- |
  32715. * | 0 | CLAMP_ADDRESSMODE | |
  32716. * | 1 | WRAP_ADDRESSMODE | |
  32717. * | 2 | MIRROR_ADDRESSMODE | |
  32718. */
  32719. wrapU: number;
  32720. /**
  32721. * | Value | Type | Description |
  32722. * | ----- | ------------------ | ----------- |
  32723. * | 0 | CLAMP_ADDRESSMODE | |
  32724. * | 1 | WRAP_ADDRESSMODE | |
  32725. * | 2 | MIRROR_ADDRESSMODE | |
  32726. */
  32727. wrapV: number;
  32728. /**
  32729. * | Value | Type | Description |
  32730. * | ----- | ------------------ | ----------- |
  32731. * | 0 | CLAMP_ADDRESSMODE | |
  32732. * | 1 | WRAP_ADDRESSMODE | |
  32733. * | 2 | MIRROR_ADDRESSMODE | |
  32734. */
  32735. wrapR: number;
  32736. /**
  32737. * With compliant hardware and browser (supporting anisotropic filtering)
  32738. * this defines the level of anisotropic filtering in the texture.
  32739. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32740. */
  32741. anisotropicFilteringLevel: number;
  32742. /**
  32743. * Define if the texture is a cube texture or if false a 2d texture.
  32744. */
  32745. get isCube(): boolean;
  32746. set isCube(value: boolean);
  32747. /**
  32748. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32749. */
  32750. get is3D(): boolean;
  32751. set is3D(value: boolean);
  32752. /**
  32753. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32754. */
  32755. get is2DArray(): boolean;
  32756. set is2DArray(value: boolean);
  32757. /**
  32758. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32759. * HDR texture are usually stored in linear space.
  32760. * This only impacts the PBR and Background materials
  32761. */
  32762. gammaSpace: boolean;
  32763. /**
  32764. * Gets or sets whether or not the texture contains RGBD data.
  32765. */
  32766. get isRGBD(): boolean;
  32767. set isRGBD(value: boolean);
  32768. /**
  32769. * Is Z inverted in the texture (useful in a cube texture).
  32770. */
  32771. invertZ: boolean;
  32772. /**
  32773. * Are mip maps generated for this texture or not.
  32774. */
  32775. get noMipmap(): boolean;
  32776. /**
  32777. * @hidden
  32778. */
  32779. lodLevelInAlpha: boolean;
  32780. /**
  32781. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32782. */
  32783. get lodGenerationOffset(): number;
  32784. set lodGenerationOffset(value: number);
  32785. /**
  32786. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32787. */
  32788. get lodGenerationScale(): number;
  32789. set lodGenerationScale(value: number);
  32790. /**
  32791. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32792. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32793. * average roughness values.
  32794. */
  32795. get linearSpecularLOD(): boolean;
  32796. set linearSpecularLOD(value: boolean);
  32797. /**
  32798. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32799. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32800. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32801. */
  32802. get irradianceTexture(): Nullable<BaseTexture>;
  32803. set irradianceTexture(value: Nullable<BaseTexture>);
  32804. /**
  32805. * Define if the texture is a render target.
  32806. */
  32807. isRenderTarget: boolean;
  32808. /**
  32809. * Define the unique id of the texture in the scene.
  32810. */
  32811. get uid(): string;
  32812. /** @hidden */
  32813. _prefiltered: boolean;
  32814. /**
  32815. * Return a string representation of the texture.
  32816. * @returns the texture as a string
  32817. */
  32818. toString(): string;
  32819. /**
  32820. * Get the class name of the texture.
  32821. * @returns "BaseTexture"
  32822. */
  32823. getClassName(): string;
  32824. /**
  32825. * Define the list of animation attached to the texture.
  32826. */
  32827. animations: Animation[];
  32828. /**
  32829. * An event triggered when the texture is disposed.
  32830. */
  32831. onDisposeObservable: Observable<BaseTexture>;
  32832. private _onDisposeObserver;
  32833. /**
  32834. * Callback triggered when the texture has been disposed.
  32835. * Kept for back compatibility, you can use the onDisposeObservable instead.
  32836. */
  32837. set onDispose(callback: () => void);
  32838. /**
  32839. * Define the current state of the loading sequence when in delayed load mode.
  32840. */
  32841. delayLoadState: number;
  32842. private _scene;
  32843. private _engine;
  32844. /** @hidden */
  32845. _texture: Nullable<InternalTexture>;
  32846. private _uid;
  32847. /**
  32848. * Define if the texture is preventinga material to render or not.
  32849. * If not and the texture is not ready, the engine will use a default black texture instead.
  32850. */
  32851. get isBlocking(): boolean;
  32852. /**
  32853. * Instantiates a new BaseTexture.
  32854. * Base class of all the textures in babylon.
  32855. * It groups all the common properties the materials, post process, lights... might need
  32856. * in order to make a correct use of the texture.
  32857. * @param sceneOrEngine Define the scene or engine the texture blongs to
  32858. */
  32859. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  32860. /**
  32861. * Get the scene the texture belongs to.
  32862. * @returns the scene or null if undefined
  32863. */
  32864. getScene(): Nullable<Scene>;
  32865. /** @hidden */
  32866. protected _getEngine(): Nullable<ThinEngine>;
  32867. /**
  32868. * Get the texture transform matrix used to offset tile the texture for istance.
  32869. * @returns the transformation matrix
  32870. */
  32871. getTextureMatrix(): Matrix;
  32872. /**
  32873. * Get the texture reflection matrix used to rotate/transform the reflection.
  32874. * @returns the reflection matrix
  32875. */
  32876. getReflectionTextureMatrix(): Matrix;
  32877. /**
  32878. * Get the underlying lower level texture from Babylon.
  32879. * @returns the insternal texture
  32880. */
  32881. getInternalTexture(): Nullable<InternalTexture>;
  32882. /**
  32883. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  32884. * @returns true if ready or not blocking
  32885. */
  32886. isReadyOrNotBlocking(): boolean;
  32887. /**
  32888. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  32889. * @returns true if fully ready
  32890. */
  32891. isReady(): boolean;
  32892. private _cachedSize;
  32893. /**
  32894. * Get the size of the texture.
  32895. * @returns the texture size.
  32896. */
  32897. getSize(): ISize;
  32898. /**
  32899. * Get the base size of the texture.
  32900. * It can be different from the size if the texture has been resized for POT for instance
  32901. * @returns the base size
  32902. */
  32903. getBaseSize(): ISize;
  32904. /**
  32905. * Update the sampling mode of the texture.
  32906. * Default is Trilinear mode.
  32907. *
  32908. * | Value | Type | Description |
  32909. * | ----- | ------------------ | ----------- |
  32910. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  32911. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  32912. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  32913. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  32914. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  32915. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  32916. * | 7 | NEAREST_LINEAR | |
  32917. * | 8 | NEAREST_NEAREST | |
  32918. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  32919. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  32920. * | 11 | LINEAR_LINEAR | |
  32921. * | 12 | LINEAR_NEAREST | |
  32922. *
  32923. * > _mag_: magnification filter (close to the viewer)
  32924. * > _min_: minification filter (far from the viewer)
  32925. * > _mip_: filter used between mip map levels
  32926. *@param samplingMode Define the new sampling mode of the texture
  32927. */
  32928. updateSamplingMode(samplingMode: number): void;
  32929. /**
  32930. * Scales the texture if is `canRescale()`
  32931. * @param ratio the resize factor we want to use to rescale
  32932. */
  32933. scale(ratio: number): void;
  32934. /**
  32935. * Get if the texture can rescale.
  32936. */
  32937. get canRescale(): boolean;
  32938. /** @hidden */
  32939. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  32940. /** @hidden */
  32941. _rebuild(): void;
  32942. /**
  32943. * Triggers the load sequence in delayed load mode.
  32944. */
  32945. delayLoad(): void;
  32946. /**
  32947. * Clones the texture.
  32948. * @returns the cloned texture
  32949. */
  32950. clone(): Nullable<BaseTexture>;
  32951. /**
  32952. * Get the texture underlying type (INT, FLOAT...)
  32953. */
  32954. get textureType(): number;
  32955. /**
  32956. * Get the texture underlying format (RGB, RGBA...)
  32957. */
  32958. get textureFormat(): number;
  32959. /**
  32960. * Indicates that textures need to be re-calculated for all materials
  32961. */
  32962. protected _markAllSubMeshesAsTexturesDirty(): void;
  32963. /**
  32964. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  32965. * This will returns an RGBA array buffer containing either in values (0-255) or
  32966. * float values (0-1) depending of the underlying buffer type.
  32967. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  32968. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  32969. * @param buffer defines a user defined buffer to fill with data (can be null)
  32970. * @returns The Array buffer containing the pixels data.
  32971. */
  32972. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  32973. /**
  32974. * Release and destroy the underlying lower level texture aka internalTexture.
  32975. */
  32976. releaseInternalTexture(): void;
  32977. /** @hidden */
  32978. get _lodTextureHigh(): Nullable<BaseTexture>;
  32979. /** @hidden */
  32980. get _lodTextureMid(): Nullable<BaseTexture>;
  32981. /** @hidden */
  32982. get _lodTextureLow(): Nullable<BaseTexture>;
  32983. /**
  32984. * Dispose the texture and release its associated resources.
  32985. */
  32986. dispose(): void;
  32987. /**
  32988. * Serialize the texture into a JSON representation that can be parsed later on.
  32989. * @returns the JSON representation of the texture
  32990. */
  32991. serialize(): any;
  32992. /**
  32993. * Helper function to be called back once a list of texture contains only ready textures.
  32994. * @param textures Define the list of textures to wait for
  32995. * @param callback Define the callback triggered once the entire list will be ready
  32996. */
  32997. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  32998. private static _isScene;
  32999. }
  33000. }
  33001. declare module BABYLON {
  33002. /**
  33003. * Options to be used when creating an effect.
  33004. */
  33005. export interface IEffectCreationOptions {
  33006. /**
  33007. * Atrributes that will be used in the shader.
  33008. */
  33009. attributes: string[];
  33010. /**
  33011. * Uniform varible names that will be set in the shader.
  33012. */
  33013. uniformsNames: string[];
  33014. /**
  33015. * Uniform buffer variable names that will be set in the shader.
  33016. */
  33017. uniformBuffersNames: string[];
  33018. /**
  33019. * Sampler texture variable names that will be set in the shader.
  33020. */
  33021. samplers: string[];
  33022. /**
  33023. * Define statements that will be set in the shader.
  33024. */
  33025. defines: any;
  33026. /**
  33027. * Possible fallbacks for this effect to improve performance when needed.
  33028. */
  33029. fallbacks: Nullable<IEffectFallbacks>;
  33030. /**
  33031. * Callback that will be called when the shader is compiled.
  33032. */
  33033. onCompiled: Nullable<(effect: Effect) => void>;
  33034. /**
  33035. * Callback that will be called if an error occurs during shader compilation.
  33036. */
  33037. onError: Nullable<(effect: Effect, errors: string) => void>;
  33038. /**
  33039. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33040. */
  33041. indexParameters?: any;
  33042. /**
  33043. * Max number of lights that can be used in the shader.
  33044. */
  33045. maxSimultaneousLights?: number;
  33046. /**
  33047. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33048. */
  33049. transformFeedbackVaryings?: Nullable<string[]>;
  33050. /**
  33051. * 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
  33052. */
  33053. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33054. }
  33055. /**
  33056. * Effect containing vertex and fragment shader that can be executed on an object.
  33057. */
  33058. export class Effect implements IDisposable {
  33059. /**
  33060. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33061. */
  33062. static ShadersRepository: string;
  33063. /**
  33064. * Enable logging of the shader code when a compilation error occurs
  33065. */
  33066. static LogShaderCodeOnCompilationError: boolean;
  33067. /**
  33068. * Name of the effect.
  33069. */
  33070. name: any;
  33071. /**
  33072. * String container all the define statements that should be set on the shader.
  33073. */
  33074. defines: string;
  33075. /**
  33076. * Callback that will be called when the shader is compiled.
  33077. */
  33078. onCompiled: Nullable<(effect: Effect) => void>;
  33079. /**
  33080. * Callback that will be called if an error occurs during shader compilation.
  33081. */
  33082. onError: Nullable<(effect: Effect, errors: string) => void>;
  33083. /**
  33084. * Callback that will be called when effect is bound.
  33085. */
  33086. onBind: Nullable<(effect: Effect) => void>;
  33087. /**
  33088. * Unique ID of the effect.
  33089. */
  33090. uniqueId: number;
  33091. /**
  33092. * Observable that will be called when the shader is compiled.
  33093. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33094. */
  33095. onCompileObservable: Observable<Effect>;
  33096. /**
  33097. * Observable that will be called if an error occurs during shader compilation.
  33098. */
  33099. onErrorObservable: Observable<Effect>;
  33100. /** @hidden */
  33101. _onBindObservable: Nullable<Observable<Effect>>;
  33102. /**
  33103. * @hidden
  33104. * Specifies if the effect was previously ready
  33105. */
  33106. _wasPreviouslyReady: boolean;
  33107. /**
  33108. * Observable that will be called when effect is bound.
  33109. */
  33110. get onBindObservable(): Observable<Effect>;
  33111. /** @hidden */
  33112. _bonesComputationForcedToCPU: boolean;
  33113. private static _uniqueIdSeed;
  33114. private _engine;
  33115. private _uniformBuffersNames;
  33116. private _uniformBuffersNamesList;
  33117. private _uniformsNames;
  33118. private _samplerList;
  33119. private _samplers;
  33120. private _isReady;
  33121. private _compilationError;
  33122. private _allFallbacksProcessed;
  33123. private _attributesNames;
  33124. private _attributes;
  33125. private _attributeLocationByName;
  33126. private _uniforms;
  33127. /**
  33128. * Key for the effect.
  33129. * @hidden
  33130. */
  33131. _key: string;
  33132. private _indexParameters;
  33133. private _fallbacks;
  33134. private _vertexSourceCode;
  33135. private _fragmentSourceCode;
  33136. private _vertexSourceCodeOverride;
  33137. private _fragmentSourceCodeOverride;
  33138. private _transformFeedbackVaryings;
  33139. /**
  33140. * Compiled shader to webGL program.
  33141. * @hidden
  33142. */
  33143. _pipelineContext: Nullable<IPipelineContext>;
  33144. private _valueCache;
  33145. private static _baseCache;
  33146. /**
  33147. * Instantiates an effect.
  33148. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33149. * @param baseName Name of the effect.
  33150. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33151. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33152. * @param samplers List of sampler variables that will be passed to the shader.
  33153. * @param engine Engine to be used to render the effect
  33154. * @param defines Define statements to be added to the shader.
  33155. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33156. * @param onCompiled Callback that will be called when the shader is compiled.
  33157. * @param onError Callback that will be called if an error occurs during shader compilation.
  33158. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33159. */
  33160. 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);
  33161. private _useFinalCode;
  33162. /**
  33163. * Unique key for this effect
  33164. */
  33165. get key(): string;
  33166. /**
  33167. * If the effect has been compiled and prepared.
  33168. * @returns if the effect is compiled and prepared.
  33169. */
  33170. isReady(): boolean;
  33171. private _isReadyInternal;
  33172. /**
  33173. * The engine the effect was initialized with.
  33174. * @returns the engine.
  33175. */
  33176. getEngine(): Engine;
  33177. /**
  33178. * The pipeline context for this effect
  33179. * @returns the associated pipeline context
  33180. */
  33181. getPipelineContext(): Nullable<IPipelineContext>;
  33182. /**
  33183. * The set of names of attribute variables for the shader.
  33184. * @returns An array of attribute names.
  33185. */
  33186. getAttributesNames(): string[];
  33187. /**
  33188. * Returns the attribute at the given index.
  33189. * @param index The index of the attribute.
  33190. * @returns The location of the attribute.
  33191. */
  33192. getAttributeLocation(index: number): number;
  33193. /**
  33194. * Returns the attribute based on the name of the variable.
  33195. * @param name of the attribute to look up.
  33196. * @returns the attribute location.
  33197. */
  33198. getAttributeLocationByName(name: string): number;
  33199. /**
  33200. * The number of attributes.
  33201. * @returns the numnber of attributes.
  33202. */
  33203. getAttributesCount(): number;
  33204. /**
  33205. * Gets the index of a uniform variable.
  33206. * @param uniformName of the uniform to look up.
  33207. * @returns the index.
  33208. */
  33209. getUniformIndex(uniformName: string): number;
  33210. /**
  33211. * Returns the attribute based on the name of the variable.
  33212. * @param uniformName of the uniform to look up.
  33213. * @returns the location of the uniform.
  33214. */
  33215. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33216. /**
  33217. * Returns an array of sampler variable names
  33218. * @returns The array of sampler variable names.
  33219. */
  33220. getSamplers(): string[];
  33221. /**
  33222. * Returns an array of uniform variable names
  33223. * @returns The array of uniform variable names.
  33224. */
  33225. getUniformNames(): string[];
  33226. /**
  33227. * Returns an array of uniform buffer variable names
  33228. * @returns The array of uniform buffer variable names.
  33229. */
  33230. getUniformBuffersNames(): string[];
  33231. /**
  33232. * Returns the index parameters used to create the effect
  33233. * @returns The index parameters object
  33234. */
  33235. getIndexParameters(): any;
  33236. /**
  33237. * The error from the last compilation.
  33238. * @returns the error string.
  33239. */
  33240. getCompilationError(): string;
  33241. /**
  33242. * Gets a boolean indicating that all fallbacks were used during compilation
  33243. * @returns true if all fallbacks were used
  33244. */
  33245. allFallbacksProcessed(): boolean;
  33246. /**
  33247. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33248. * @param func The callback to be used.
  33249. */
  33250. executeWhenCompiled(func: (effect: Effect) => void): void;
  33251. private _checkIsReady;
  33252. private _loadShader;
  33253. /**
  33254. * Gets the vertex shader source code of this effect
  33255. */
  33256. get vertexSourceCode(): string;
  33257. /**
  33258. * Gets the fragment shader source code of this effect
  33259. */
  33260. get fragmentSourceCode(): string;
  33261. /**
  33262. * Recompiles the webGL program
  33263. * @param vertexSourceCode The source code for the vertex shader.
  33264. * @param fragmentSourceCode The source code for the fragment shader.
  33265. * @param onCompiled Callback called when completed.
  33266. * @param onError Callback called on error.
  33267. * @hidden
  33268. */
  33269. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33270. /**
  33271. * Prepares the effect
  33272. * @hidden
  33273. */
  33274. _prepareEffect(): void;
  33275. private _getShaderCodeAndErrorLine;
  33276. private _processCompilationErrors;
  33277. /**
  33278. * Checks if the effect is supported. (Must be called after compilation)
  33279. */
  33280. get isSupported(): boolean;
  33281. /**
  33282. * Binds a texture to the engine to be used as output of the shader.
  33283. * @param channel Name of the output variable.
  33284. * @param texture Texture to bind.
  33285. * @hidden
  33286. */
  33287. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33288. /**
  33289. * Sets a texture on the engine to be used in the shader.
  33290. * @param channel Name of the sampler variable.
  33291. * @param texture Texture to set.
  33292. */
  33293. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33294. /**
  33295. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33296. * @param channel Name of the sampler variable.
  33297. * @param texture Texture to set.
  33298. */
  33299. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33300. /**
  33301. * Sets an array of textures on the engine to be used in the shader.
  33302. * @param channel Name of the variable.
  33303. * @param textures Textures to set.
  33304. */
  33305. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33306. /**
  33307. * 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)
  33308. * @param channel Name of the sampler variable.
  33309. * @param postProcess Post process to get the input texture from.
  33310. */
  33311. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33312. /**
  33313. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33314. * 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)
  33315. * @param channel Name of the sampler variable.
  33316. * @param postProcess Post process to get the output texture from.
  33317. */
  33318. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33319. /** @hidden */
  33320. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33321. /** @hidden */
  33322. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33323. /** @hidden */
  33324. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33325. /** @hidden */
  33326. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33327. /**
  33328. * Binds a buffer to a uniform.
  33329. * @param buffer Buffer to bind.
  33330. * @param name Name of the uniform variable to bind to.
  33331. */
  33332. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33333. /**
  33334. * Binds block to a uniform.
  33335. * @param blockName Name of the block to bind.
  33336. * @param index Index to bind.
  33337. */
  33338. bindUniformBlock(blockName: string, index: number): void;
  33339. /**
  33340. * Sets an interger value on a uniform variable.
  33341. * @param uniformName Name of the variable.
  33342. * @param value Value to be set.
  33343. * @returns this effect.
  33344. */
  33345. setInt(uniformName: string, value: number): Effect;
  33346. /**
  33347. * Sets an int array on a uniform variable.
  33348. * @param uniformName Name of the variable.
  33349. * @param array array to be set.
  33350. * @returns this effect.
  33351. */
  33352. setIntArray(uniformName: string, array: Int32Array): Effect;
  33353. /**
  33354. * 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)
  33355. * @param uniformName Name of the variable.
  33356. * @param array array to be set.
  33357. * @returns this effect.
  33358. */
  33359. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33360. /**
  33361. * 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)
  33362. * @param uniformName Name of the variable.
  33363. * @param array array to be set.
  33364. * @returns this effect.
  33365. */
  33366. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33367. /**
  33368. * 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)
  33369. * @param uniformName Name of the variable.
  33370. * @param array array to be set.
  33371. * @returns this effect.
  33372. */
  33373. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33374. /**
  33375. * Sets an float array on a uniform variable.
  33376. * @param uniformName Name of the variable.
  33377. * @param array array to be set.
  33378. * @returns this effect.
  33379. */
  33380. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33381. /**
  33382. * 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)
  33383. * @param uniformName Name of the variable.
  33384. * @param array array to be set.
  33385. * @returns this effect.
  33386. */
  33387. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33388. /**
  33389. * 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)
  33390. * @param uniformName Name of the variable.
  33391. * @param array array to be set.
  33392. * @returns this effect.
  33393. */
  33394. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33395. /**
  33396. * 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)
  33397. * @param uniformName Name of the variable.
  33398. * @param array array to be set.
  33399. * @returns this effect.
  33400. */
  33401. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33402. /**
  33403. * Sets an array on a uniform variable.
  33404. * @param uniformName Name of the variable.
  33405. * @param array array to be set.
  33406. * @returns this effect.
  33407. */
  33408. setArray(uniformName: string, array: number[]): Effect;
  33409. /**
  33410. * 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)
  33411. * @param uniformName Name of the variable.
  33412. * @param array array to be set.
  33413. * @returns this effect.
  33414. */
  33415. setArray2(uniformName: string, array: number[]): Effect;
  33416. /**
  33417. * 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)
  33418. * @param uniformName Name of the variable.
  33419. * @param array array to be set.
  33420. * @returns this effect.
  33421. */
  33422. setArray3(uniformName: string, array: number[]): Effect;
  33423. /**
  33424. * 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)
  33425. * @param uniformName Name of the variable.
  33426. * @param array array to be set.
  33427. * @returns this effect.
  33428. */
  33429. setArray4(uniformName: string, array: number[]): Effect;
  33430. /**
  33431. * Sets matrices on a uniform variable.
  33432. * @param uniformName Name of the variable.
  33433. * @param matrices matrices to be set.
  33434. * @returns this effect.
  33435. */
  33436. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33437. /**
  33438. * Sets matrix on a uniform variable.
  33439. * @param uniformName Name of the variable.
  33440. * @param matrix matrix to be set.
  33441. * @returns this effect.
  33442. */
  33443. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33444. /**
  33445. * 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)
  33446. * @param uniformName Name of the variable.
  33447. * @param matrix matrix to be set.
  33448. * @returns this effect.
  33449. */
  33450. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33451. /**
  33452. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33453. * @param uniformName Name of the variable.
  33454. * @param matrix matrix to be set.
  33455. * @returns this effect.
  33456. */
  33457. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33458. /**
  33459. * Sets a float on a uniform variable.
  33460. * @param uniformName Name of the variable.
  33461. * @param value value to be set.
  33462. * @returns this effect.
  33463. */
  33464. setFloat(uniformName: string, value: number): Effect;
  33465. /**
  33466. * Sets a boolean on a uniform variable.
  33467. * @param uniformName Name of the variable.
  33468. * @param bool value to be set.
  33469. * @returns this effect.
  33470. */
  33471. setBool(uniformName: string, bool: boolean): Effect;
  33472. /**
  33473. * Sets a Vector2 on a uniform variable.
  33474. * @param uniformName Name of the variable.
  33475. * @param vector2 vector2 to be set.
  33476. * @returns this effect.
  33477. */
  33478. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33479. /**
  33480. * Sets a float2 on a uniform variable.
  33481. * @param uniformName Name of the variable.
  33482. * @param x First float in float2.
  33483. * @param y Second float in float2.
  33484. * @returns this effect.
  33485. */
  33486. setFloat2(uniformName: string, x: number, y: number): Effect;
  33487. /**
  33488. * Sets a Vector3 on a uniform variable.
  33489. * @param uniformName Name of the variable.
  33490. * @param vector3 Value to be set.
  33491. * @returns this effect.
  33492. */
  33493. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33494. /**
  33495. * Sets a float3 on a uniform variable.
  33496. * @param uniformName Name of the variable.
  33497. * @param x First float in float3.
  33498. * @param y Second float in float3.
  33499. * @param z Third float in float3.
  33500. * @returns this effect.
  33501. */
  33502. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33503. /**
  33504. * Sets a Vector4 on a uniform variable.
  33505. * @param uniformName Name of the variable.
  33506. * @param vector4 Value to be set.
  33507. * @returns this effect.
  33508. */
  33509. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33510. /**
  33511. * Sets a float4 on a uniform variable.
  33512. * @param uniformName Name of the variable.
  33513. * @param x First float in float4.
  33514. * @param y Second float in float4.
  33515. * @param z Third float in float4.
  33516. * @param w Fourth float in float4.
  33517. * @returns this effect.
  33518. */
  33519. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33520. /**
  33521. * Sets a Color3 on a uniform variable.
  33522. * @param uniformName Name of the variable.
  33523. * @param color3 Value to be set.
  33524. * @returns this effect.
  33525. */
  33526. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33527. /**
  33528. * Sets a Color4 on a uniform variable.
  33529. * @param uniformName Name of the variable.
  33530. * @param color3 Value to be set.
  33531. * @param alpha Alpha value to be set.
  33532. * @returns this effect.
  33533. */
  33534. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33535. /**
  33536. * Sets a Color4 on a uniform variable
  33537. * @param uniformName defines the name of the variable
  33538. * @param color4 defines the value to be set
  33539. * @returns this effect.
  33540. */
  33541. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33542. /** Release all associated resources */
  33543. dispose(): void;
  33544. /**
  33545. * This function will add a new shader to the shader store
  33546. * @param name the name of the shader
  33547. * @param pixelShader optional pixel shader content
  33548. * @param vertexShader optional vertex shader content
  33549. */
  33550. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33551. /**
  33552. * Store of each shader (The can be looked up using effect.key)
  33553. */
  33554. static ShadersStore: {
  33555. [key: string]: string;
  33556. };
  33557. /**
  33558. * Store of each included file for a shader (The can be looked up using effect.key)
  33559. */
  33560. static IncludesShadersStore: {
  33561. [key: string]: string;
  33562. };
  33563. /**
  33564. * Resets the cache of effects.
  33565. */
  33566. static ResetCache(): void;
  33567. }
  33568. }
  33569. declare module BABYLON {
  33570. /**
  33571. * Interface used to describe the capabilities of the engine relatively to the current browser
  33572. */
  33573. export interface EngineCapabilities {
  33574. /** Maximum textures units per fragment shader */
  33575. maxTexturesImageUnits: number;
  33576. /** Maximum texture units per vertex shader */
  33577. maxVertexTextureImageUnits: number;
  33578. /** Maximum textures units in the entire pipeline */
  33579. maxCombinedTexturesImageUnits: number;
  33580. /** Maximum texture size */
  33581. maxTextureSize: number;
  33582. /** Maximum texture samples */
  33583. maxSamples?: number;
  33584. /** Maximum cube texture size */
  33585. maxCubemapTextureSize: number;
  33586. /** Maximum render texture size */
  33587. maxRenderTextureSize: number;
  33588. /** Maximum number of vertex attributes */
  33589. maxVertexAttribs: number;
  33590. /** Maximum number of varyings */
  33591. maxVaryingVectors: number;
  33592. /** Maximum number of uniforms per vertex shader */
  33593. maxVertexUniformVectors: number;
  33594. /** Maximum number of uniforms per fragment shader */
  33595. maxFragmentUniformVectors: number;
  33596. /** Defines if standard derivates (dx/dy) are supported */
  33597. standardDerivatives: boolean;
  33598. /** Defines if s3tc texture compression is supported */
  33599. s3tc?: WEBGL_compressed_texture_s3tc;
  33600. /** Defines if pvrtc texture compression is supported */
  33601. pvrtc: any;
  33602. /** Defines if etc1 texture compression is supported */
  33603. etc1: any;
  33604. /** Defines if etc2 texture compression is supported */
  33605. etc2: any;
  33606. /** Defines if astc texture compression is supported */
  33607. astc: any;
  33608. /** Defines if float textures are supported */
  33609. textureFloat: boolean;
  33610. /** Defines if vertex array objects are supported */
  33611. vertexArrayObject: boolean;
  33612. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33613. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33614. /** Gets the maximum level of anisotropy supported */
  33615. maxAnisotropy: number;
  33616. /** Defines if instancing is supported */
  33617. instancedArrays: boolean;
  33618. /** Defines if 32 bits indices are supported */
  33619. uintIndices: boolean;
  33620. /** Defines if high precision shaders are supported */
  33621. highPrecisionShaderSupported: boolean;
  33622. /** Defines if depth reading in the fragment shader is supported */
  33623. fragmentDepthSupported: boolean;
  33624. /** Defines if float texture linear filtering is supported*/
  33625. textureFloatLinearFiltering: boolean;
  33626. /** Defines if rendering to float textures is supported */
  33627. textureFloatRender: boolean;
  33628. /** Defines if half float textures are supported*/
  33629. textureHalfFloat: boolean;
  33630. /** Defines if half float texture linear filtering is supported*/
  33631. textureHalfFloatLinearFiltering: boolean;
  33632. /** Defines if rendering to half float textures is supported */
  33633. textureHalfFloatRender: boolean;
  33634. /** Defines if textureLOD shader command is supported */
  33635. textureLOD: boolean;
  33636. /** Defines if draw buffers extension is supported */
  33637. drawBuffersExtension: boolean;
  33638. /** Defines if depth textures are supported */
  33639. depthTextureExtension: boolean;
  33640. /** Defines if float color buffer are supported */
  33641. colorBufferFloat: boolean;
  33642. /** Gets disjoint timer query extension (null if not supported) */
  33643. timerQuery?: EXT_disjoint_timer_query;
  33644. /** Defines if timestamp can be used with timer query */
  33645. canUseTimestampForTimerQuery: boolean;
  33646. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33647. multiview?: any;
  33648. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33649. oculusMultiview?: any;
  33650. /** Function used to let the system compiles shaders in background */
  33651. parallelShaderCompile?: {
  33652. COMPLETION_STATUS_KHR: number;
  33653. };
  33654. /** Max number of texture samples for MSAA */
  33655. maxMSAASamples: number;
  33656. /** Defines if the blend min max extension is supported */
  33657. blendMinMax: boolean;
  33658. }
  33659. }
  33660. declare module BABYLON {
  33661. /**
  33662. * @hidden
  33663. **/
  33664. export class DepthCullingState {
  33665. private _isDepthTestDirty;
  33666. private _isDepthMaskDirty;
  33667. private _isDepthFuncDirty;
  33668. private _isCullFaceDirty;
  33669. private _isCullDirty;
  33670. private _isZOffsetDirty;
  33671. private _isFrontFaceDirty;
  33672. private _depthTest;
  33673. private _depthMask;
  33674. private _depthFunc;
  33675. private _cull;
  33676. private _cullFace;
  33677. private _zOffset;
  33678. private _frontFace;
  33679. /**
  33680. * Initializes the state.
  33681. */
  33682. constructor();
  33683. get isDirty(): boolean;
  33684. get zOffset(): number;
  33685. set zOffset(value: number);
  33686. get cullFace(): Nullable<number>;
  33687. set cullFace(value: Nullable<number>);
  33688. get cull(): Nullable<boolean>;
  33689. set cull(value: Nullable<boolean>);
  33690. get depthFunc(): Nullable<number>;
  33691. set depthFunc(value: Nullable<number>);
  33692. get depthMask(): boolean;
  33693. set depthMask(value: boolean);
  33694. get depthTest(): boolean;
  33695. set depthTest(value: boolean);
  33696. get frontFace(): Nullable<number>;
  33697. set frontFace(value: Nullable<number>);
  33698. reset(): void;
  33699. apply(gl: WebGLRenderingContext): void;
  33700. }
  33701. }
  33702. declare module BABYLON {
  33703. /**
  33704. * @hidden
  33705. **/
  33706. export class StencilState {
  33707. /** 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 */
  33708. static readonly ALWAYS: number;
  33709. /** Passed to stencilOperation to specify that stencil value must be kept */
  33710. static readonly KEEP: number;
  33711. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33712. static readonly REPLACE: number;
  33713. private _isStencilTestDirty;
  33714. private _isStencilMaskDirty;
  33715. private _isStencilFuncDirty;
  33716. private _isStencilOpDirty;
  33717. private _stencilTest;
  33718. private _stencilMask;
  33719. private _stencilFunc;
  33720. private _stencilFuncRef;
  33721. private _stencilFuncMask;
  33722. private _stencilOpStencilFail;
  33723. private _stencilOpDepthFail;
  33724. private _stencilOpStencilDepthPass;
  33725. get isDirty(): boolean;
  33726. get stencilFunc(): number;
  33727. set stencilFunc(value: number);
  33728. get stencilFuncRef(): number;
  33729. set stencilFuncRef(value: number);
  33730. get stencilFuncMask(): number;
  33731. set stencilFuncMask(value: number);
  33732. get stencilOpStencilFail(): number;
  33733. set stencilOpStencilFail(value: number);
  33734. get stencilOpDepthFail(): number;
  33735. set stencilOpDepthFail(value: number);
  33736. get stencilOpStencilDepthPass(): number;
  33737. set stencilOpStencilDepthPass(value: number);
  33738. get stencilMask(): number;
  33739. set stencilMask(value: number);
  33740. get stencilTest(): boolean;
  33741. set stencilTest(value: boolean);
  33742. constructor();
  33743. reset(): void;
  33744. apply(gl: WebGLRenderingContext): void;
  33745. }
  33746. }
  33747. declare module BABYLON {
  33748. /**
  33749. * @hidden
  33750. **/
  33751. export class AlphaState {
  33752. private _isAlphaBlendDirty;
  33753. private _isBlendFunctionParametersDirty;
  33754. private _isBlendEquationParametersDirty;
  33755. private _isBlendConstantsDirty;
  33756. private _alphaBlend;
  33757. private _blendFunctionParameters;
  33758. private _blendEquationParameters;
  33759. private _blendConstants;
  33760. /**
  33761. * Initializes the state.
  33762. */
  33763. constructor();
  33764. get isDirty(): boolean;
  33765. get alphaBlend(): boolean;
  33766. set alphaBlend(value: boolean);
  33767. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33768. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33769. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33770. reset(): void;
  33771. apply(gl: WebGLRenderingContext): void;
  33772. }
  33773. }
  33774. declare module BABYLON {
  33775. /** @hidden */
  33776. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33777. attributeProcessor(attribute: string): string;
  33778. varyingProcessor(varying: string, isFragment: boolean): string;
  33779. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33780. }
  33781. }
  33782. declare module BABYLON {
  33783. /**
  33784. * Interface for attribute information associated with buffer instanciation
  33785. */
  33786. export interface InstancingAttributeInfo {
  33787. /**
  33788. * Name of the GLSL attribute
  33789. * if attribute index is not specified, this is used to retrieve the index from the effect
  33790. */
  33791. attributeName: string;
  33792. /**
  33793. * Index/offset of the attribute in the vertex shader
  33794. * if not specified, this will be computes from the name.
  33795. */
  33796. index?: number;
  33797. /**
  33798. * size of the attribute, 1, 2, 3 or 4
  33799. */
  33800. attributeSize: number;
  33801. /**
  33802. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33803. */
  33804. offset: number;
  33805. /**
  33806. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33807. * default to 1
  33808. */
  33809. divisor?: number;
  33810. /**
  33811. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33812. * default is FLOAT
  33813. */
  33814. attributeType?: number;
  33815. /**
  33816. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33817. */
  33818. normalized?: boolean;
  33819. }
  33820. }
  33821. declare module BABYLON {
  33822. interface ThinEngine {
  33823. /**
  33824. * Update a video texture
  33825. * @param texture defines the texture to update
  33826. * @param video defines the video element to use
  33827. * @param invertY defines if data must be stored with Y axis inverted
  33828. */
  33829. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  33830. }
  33831. }
  33832. declare module BABYLON {
  33833. /**
  33834. * Settings for finer control over video usage
  33835. */
  33836. export interface VideoTextureSettings {
  33837. /**
  33838. * Applies `autoplay` to video, if specified
  33839. */
  33840. autoPlay?: boolean;
  33841. /**
  33842. * Applies `loop` to video, if specified
  33843. */
  33844. loop?: boolean;
  33845. /**
  33846. * Automatically updates internal texture from video at every frame in the render loop
  33847. */
  33848. autoUpdateTexture: boolean;
  33849. /**
  33850. * Image src displayed during the video loading or until the user interacts with the video.
  33851. */
  33852. poster?: string;
  33853. }
  33854. /**
  33855. * If you want to display a video in your scene, this is the special texture for that.
  33856. * This special texture works similar to other textures, with the exception of a few parameters.
  33857. * @see https://doc.babylonjs.com/how_to/video_texture
  33858. */
  33859. export class VideoTexture extends Texture {
  33860. /**
  33861. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33862. */
  33863. readonly autoUpdateTexture: boolean;
  33864. /**
  33865. * The video instance used by the texture internally
  33866. */
  33867. readonly video: HTMLVideoElement;
  33868. private _onUserActionRequestedObservable;
  33869. /**
  33870. * Event triggerd when a dom action is required by the user to play the video.
  33871. * This happens due to recent changes in browser policies preventing video to auto start.
  33872. */
  33873. get onUserActionRequestedObservable(): Observable<Texture>;
  33874. private _generateMipMaps;
  33875. private _stillImageCaptured;
  33876. private _displayingPosterTexture;
  33877. private _settings;
  33878. private _createInternalTextureOnEvent;
  33879. private _frameId;
  33880. private _currentSrc;
  33881. /**
  33882. * Creates a video texture.
  33883. * If you want to display a video in your scene, this is the special texture for that.
  33884. * This special texture works similar to other textures, with the exception of a few parameters.
  33885. * @see https://doc.babylonjs.com/how_to/video_texture
  33886. * @param name optional name, will detect from video source, if not defined
  33887. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  33888. * @param scene is obviously the current scene.
  33889. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33890. * @param invertY is false by default but can be used to invert video on Y axis
  33891. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33892. * @param settings allows finer control over video usage
  33893. */
  33894. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33895. private _getName;
  33896. private _getVideo;
  33897. private _createInternalTexture;
  33898. private reset;
  33899. /**
  33900. * @hidden Internal method to initiate `update`.
  33901. */
  33902. _rebuild(): void;
  33903. /**
  33904. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33905. */
  33906. update(): void;
  33907. /**
  33908. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33909. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33910. */
  33911. updateTexture(isVisible: boolean): void;
  33912. protected _updateInternalTexture: () => void;
  33913. /**
  33914. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33915. * @param url New url.
  33916. */
  33917. updateURL(url: string): void;
  33918. /**
  33919. * Clones the texture.
  33920. * @returns the cloned texture
  33921. */
  33922. clone(): VideoTexture;
  33923. /**
  33924. * Dispose the texture and release its associated resources.
  33925. */
  33926. dispose(): void;
  33927. /**
  33928. * Creates a video texture straight from a stream.
  33929. * @param scene Define the scene the texture should be created in
  33930. * @param stream Define the stream the texture should be created from
  33931. * @returns The created video texture as a promise
  33932. */
  33933. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  33934. /**
  33935. * Creates a video texture straight from your WebCam video feed.
  33936. * @param scene Define the scene the texture should be created in
  33937. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33938. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33939. * @returns The created video texture as a promise
  33940. */
  33941. static CreateFromWebCamAsync(scene: Scene, constraints: {
  33942. minWidth: number;
  33943. maxWidth: number;
  33944. minHeight: number;
  33945. maxHeight: number;
  33946. deviceId: string;
  33947. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  33948. /**
  33949. * Creates a video texture straight from your WebCam video feed.
  33950. * @param scene Define the scene the texture should be created in
  33951. * @param onReady Define a callback to triggered once the texture will be ready
  33952. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33953. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33954. */
  33955. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33956. minWidth: number;
  33957. maxWidth: number;
  33958. minHeight: number;
  33959. maxHeight: number;
  33960. deviceId: string;
  33961. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  33962. }
  33963. }
  33964. declare module BABYLON {
  33965. /**
  33966. * Defines the interface used by objects working like Scene
  33967. * @hidden
  33968. */
  33969. export interface ISceneLike {
  33970. _addPendingData(data: any): void;
  33971. _removePendingData(data: any): void;
  33972. offlineProvider: IOfflineProvider;
  33973. }
  33974. /** Interface defining initialization parameters for Engine class */
  33975. export interface EngineOptions extends WebGLContextAttributes {
  33976. /**
  33977. * Defines if the engine should no exceed a specified device ratio
  33978. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  33979. */
  33980. limitDeviceRatio?: number;
  33981. /**
  33982. * Defines if webvr should be enabled automatically
  33983. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33984. */
  33985. autoEnableWebVR?: boolean;
  33986. /**
  33987. * Defines if webgl2 should be turned off even if supported
  33988. * @see http://doc.babylonjs.com/features/webgl2
  33989. */
  33990. disableWebGL2Support?: boolean;
  33991. /**
  33992. * Defines if webaudio should be initialized as well
  33993. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33994. */
  33995. audioEngine?: boolean;
  33996. /**
  33997. * Defines if animations should run using a deterministic lock step
  33998. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33999. */
  34000. deterministicLockstep?: boolean;
  34001. /** Defines the maximum steps to use with deterministic lock step mode */
  34002. lockstepMaxSteps?: number;
  34003. /** Defines the seconds between each deterministic lock step */
  34004. timeStep?: number;
  34005. /**
  34006. * Defines that engine should ignore context lost events
  34007. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34008. */
  34009. doNotHandleContextLost?: boolean;
  34010. /**
  34011. * Defines that engine should ignore modifying touch action attribute and style
  34012. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34013. */
  34014. doNotHandleTouchAction?: boolean;
  34015. /**
  34016. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34017. */
  34018. useHighPrecisionFloats?: boolean;
  34019. }
  34020. /**
  34021. * The base engine class (root of all engines)
  34022. */
  34023. export class ThinEngine {
  34024. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34025. static ExceptionList: ({
  34026. key: string;
  34027. capture: string;
  34028. captureConstraint: number;
  34029. targets: string[];
  34030. } | {
  34031. key: string;
  34032. capture: null;
  34033. captureConstraint: null;
  34034. targets: string[];
  34035. })[];
  34036. /** @hidden */
  34037. static _TextureLoaders: IInternalTextureLoader[];
  34038. /**
  34039. * Returns the current npm package of the sdk
  34040. */
  34041. static get NpmPackage(): string;
  34042. /**
  34043. * Returns the current version of the framework
  34044. */
  34045. static get Version(): string;
  34046. /**
  34047. * Returns a string describing the current engine
  34048. */
  34049. get description(): string;
  34050. /**
  34051. * Gets or sets the epsilon value used by collision engine
  34052. */
  34053. static CollisionsEpsilon: number;
  34054. /**
  34055. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34056. */
  34057. static get ShadersRepository(): string;
  34058. static set ShadersRepository(value: string);
  34059. /** @hidden */
  34060. _shaderProcessor: IShaderProcessor;
  34061. /**
  34062. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34063. */
  34064. forcePOTTextures: boolean;
  34065. /**
  34066. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34067. */
  34068. isFullscreen: boolean;
  34069. /**
  34070. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34071. */
  34072. cullBackFaces: boolean;
  34073. /**
  34074. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34075. */
  34076. renderEvenInBackground: boolean;
  34077. /**
  34078. * Gets or sets a boolean indicating that cache can be kept between frames
  34079. */
  34080. preventCacheWipeBetweenFrames: boolean;
  34081. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34082. validateShaderPrograms: boolean;
  34083. /**
  34084. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34085. * This can provide greater z depth for distant objects.
  34086. */
  34087. useReverseDepthBuffer: boolean;
  34088. /**
  34089. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34090. */
  34091. disableUniformBuffers: boolean;
  34092. /** @hidden */
  34093. _uniformBuffers: UniformBuffer[];
  34094. /**
  34095. * Gets a boolean indicating that the engine supports uniform buffers
  34096. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34097. */
  34098. get supportsUniformBuffers(): boolean;
  34099. /** @hidden */
  34100. _gl: WebGLRenderingContext;
  34101. /** @hidden */
  34102. _webGLVersion: number;
  34103. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34104. protected _windowIsBackground: boolean;
  34105. protected _creationOptions: EngineOptions;
  34106. protected _highPrecisionShadersAllowed: boolean;
  34107. /** @hidden */
  34108. get _shouldUseHighPrecisionShader(): boolean;
  34109. /**
  34110. * Gets a boolean indicating that only power of 2 textures are supported
  34111. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34112. */
  34113. get needPOTTextures(): boolean;
  34114. /** @hidden */
  34115. _badOS: boolean;
  34116. /** @hidden */
  34117. _badDesktopOS: boolean;
  34118. private _hardwareScalingLevel;
  34119. /** @hidden */
  34120. _caps: EngineCapabilities;
  34121. private _isStencilEnable;
  34122. private _glVersion;
  34123. private _glRenderer;
  34124. private _glVendor;
  34125. /** @hidden */
  34126. _videoTextureSupported: boolean;
  34127. protected _renderingQueueLaunched: boolean;
  34128. protected _activeRenderLoops: (() => void)[];
  34129. /**
  34130. * Observable signaled when a context lost event is raised
  34131. */
  34132. onContextLostObservable: Observable<ThinEngine>;
  34133. /**
  34134. * Observable signaled when a context restored event is raised
  34135. */
  34136. onContextRestoredObservable: Observable<ThinEngine>;
  34137. private _onContextLost;
  34138. private _onContextRestored;
  34139. protected _contextWasLost: boolean;
  34140. /** @hidden */
  34141. _doNotHandleContextLost: boolean;
  34142. /**
  34143. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34144. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34145. */
  34146. get doNotHandleContextLost(): boolean;
  34147. set doNotHandleContextLost(value: boolean);
  34148. /**
  34149. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34150. */
  34151. disableVertexArrayObjects: boolean;
  34152. /** @hidden */
  34153. protected _colorWrite: boolean;
  34154. /** @hidden */
  34155. protected _colorWriteChanged: boolean;
  34156. /** @hidden */
  34157. protected _depthCullingState: DepthCullingState;
  34158. /** @hidden */
  34159. protected _stencilState: StencilState;
  34160. /** @hidden */
  34161. _alphaState: AlphaState;
  34162. /** @hidden */
  34163. _alphaMode: number;
  34164. /** @hidden */
  34165. _alphaEquation: number;
  34166. /** @hidden */
  34167. _internalTexturesCache: InternalTexture[];
  34168. /** @hidden */
  34169. protected _activeChannel: number;
  34170. private _currentTextureChannel;
  34171. /** @hidden */
  34172. protected _boundTexturesCache: {
  34173. [key: string]: Nullable<InternalTexture>;
  34174. };
  34175. /** @hidden */
  34176. protected _currentEffect: Nullable<Effect>;
  34177. /** @hidden */
  34178. protected _currentProgram: Nullable<WebGLProgram>;
  34179. private _compiledEffects;
  34180. private _vertexAttribArraysEnabled;
  34181. /** @hidden */
  34182. protected _cachedViewport: Nullable<IViewportLike>;
  34183. private _cachedVertexArrayObject;
  34184. /** @hidden */
  34185. protected _cachedVertexBuffers: any;
  34186. /** @hidden */
  34187. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34188. /** @hidden */
  34189. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34190. /** @hidden */
  34191. _currentRenderTarget: Nullable<InternalTexture>;
  34192. private _uintIndicesCurrentlySet;
  34193. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34194. /** @hidden */
  34195. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34196. /** @hidden */
  34197. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34198. private _currentBufferPointers;
  34199. private _currentInstanceLocations;
  34200. private _currentInstanceBuffers;
  34201. private _textureUnits;
  34202. /** @hidden */
  34203. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34204. /** @hidden */
  34205. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34206. /** @hidden */
  34207. _boundRenderFunction: any;
  34208. private _vaoRecordInProgress;
  34209. private _mustWipeVertexAttributes;
  34210. private _emptyTexture;
  34211. private _emptyCubeTexture;
  34212. private _emptyTexture3D;
  34213. private _emptyTexture2DArray;
  34214. /** @hidden */
  34215. _frameHandler: number;
  34216. private _nextFreeTextureSlots;
  34217. private _maxSimultaneousTextures;
  34218. private _activeRequests;
  34219. /** @hidden */
  34220. _transformTextureUrl: Nullable<(url: string) => string>;
  34221. protected get _supportsHardwareTextureRescaling(): boolean;
  34222. private _framebufferDimensionsObject;
  34223. /**
  34224. * sets the object from which width and height will be taken from when getting render width and height
  34225. * Will fallback to the gl object
  34226. * @param dimensions the framebuffer width and height that will be used.
  34227. */
  34228. set framebufferDimensionsObject(dimensions: Nullable<{
  34229. framebufferWidth: number;
  34230. framebufferHeight: number;
  34231. }>);
  34232. /**
  34233. * Gets the current viewport
  34234. */
  34235. get currentViewport(): Nullable<IViewportLike>;
  34236. /**
  34237. * Gets the default empty texture
  34238. */
  34239. get emptyTexture(): InternalTexture;
  34240. /**
  34241. * Gets the default empty 3D texture
  34242. */
  34243. get emptyTexture3D(): InternalTexture;
  34244. /**
  34245. * Gets the default empty 2D array texture
  34246. */
  34247. get emptyTexture2DArray(): InternalTexture;
  34248. /**
  34249. * Gets the default empty cube texture
  34250. */
  34251. get emptyCubeTexture(): InternalTexture;
  34252. /**
  34253. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34254. */
  34255. readonly premultipliedAlpha: boolean;
  34256. /**
  34257. * Observable event triggered before each texture is initialized
  34258. */
  34259. onBeforeTextureInitObservable: Observable<Texture>;
  34260. /**
  34261. * Creates a new engine
  34262. * @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
  34263. * @param antialias defines enable antialiasing (default: false)
  34264. * @param options defines further options to be sent to the getContext() function
  34265. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34266. */
  34267. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34268. private _rebuildInternalTextures;
  34269. private _rebuildEffects;
  34270. /**
  34271. * Gets a boolean indicating if all created effects are ready
  34272. * @returns true if all effects are ready
  34273. */
  34274. areAllEffectsReady(): boolean;
  34275. protected _rebuildBuffers(): void;
  34276. protected _initGLContext(): void;
  34277. /**
  34278. * Gets version of the current webGL context
  34279. */
  34280. get webGLVersion(): number;
  34281. /**
  34282. * Gets a string idenfifying the name of the class
  34283. * @returns "Engine" string
  34284. */
  34285. getClassName(): string;
  34286. /**
  34287. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34288. */
  34289. get isStencilEnable(): boolean;
  34290. /** @hidden */
  34291. _prepareWorkingCanvas(): void;
  34292. /**
  34293. * Reset the texture cache to empty state
  34294. */
  34295. resetTextureCache(): void;
  34296. /**
  34297. * Gets an object containing information about the current webGL context
  34298. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34299. */
  34300. getGlInfo(): {
  34301. vendor: string;
  34302. renderer: string;
  34303. version: string;
  34304. };
  34305. /**
  34306. * Defines the hardware scaling level.
  34307. * By default the hardware scaling level is computed from the window device ratio.
  34308. * 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.
  34309. * @param level defines the level to use
  34310. */
  34311. setHardwareScalingLevel(level: number): void;
  34312. /**
  34313. * Gets the current hardware scaling level.
  34314. * By default the hardware scaling level is computed from the window device ratio.
  34315. * 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.
  34316. * @returns a number indicating the current hardware scaling level
  34317. */
  34318. getHardwareScalingLevel(): number;
  34319. /**
  34320. * Gets the list of loaded textures
  34321. * @returns an array containing all loaded textures
  34322. */
  34323. getLoadedTexturesCache(): InternalTexture[];
  34324. /**
  34325. * Gets the object containing all engine capabilities
  34326. * @returns the EngineCapabilities object
  34327. */
  34328. getCaps(): EngineCapabilities;
  34329. /**
  34330. * stop executing a render loop function and remove it from the execution array
  34331. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34332. */
  34333. stopRenderLoop(renderFunction?: () => void): void;
  34334. /** @hidden */
  34335. _renderLoop(): void;
  34336. /**
  34337. * Gets the HTML canvas attached with the current webGL context
  34338. * @returns a HTML canvas
  34339. */
  34340. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34341. /**
  34342. * Gets host window
  34343. * @returns the host window object
  34344. */
  34345. getHostWindow(): Nullable<Window>;
  34346. /**
  34347. * Gets the current render width
  34348. * @param useScreen defines if screen size must be used (or the current render target if any)
  34349. * @returns a number defining the current render width
  34350. */
  34351. getRenderWidth(useScreen?: boolean): number;
  34352. /**
  34353. * Gets the current render height
  34354. * @param useScreen defines if screen size must be used (or the current render target if any)
  34355. * @returns a number defining the current render height
  34356. */
  34357. getRenderHeight(useScreen?: boolean): number;
  34358. /**
  34359. * Can be used to override the current requestAnimationFrame requester.
  34360. * @hidden
  34361. */
  34362. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34363. /**
  34364. * Register and execute a render loop. The engine can have more than one render function
  34365. * @param renderFunction defines the function to continuously execute
  34366. */
  34367. runRenderLoop(renderFunction: () => void): void;
  34368. /**
  34369. * Clear the current render buffer or the current render target (if any is set up)
  34370. * @param color defines the color to use
  34371. * @param backBuffer defines if the back buffer must be cleared
  34372. * @param depth defines if the depth buffer must be cleared
  34373. * @param stencil defines if the stencil buffer must be cleared
  34374. */
  34375. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34376. private _viewportCached;
  34377. /** @hidden */
  34378. _viewport(x: number, y: number, width: number, height: number): void;
  34379. /**
  34380. * Set the WebGL's viewport
  34381. * @param viewport defines the viewport element to be used
  34382. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34383. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34384. */
  34385. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34386. /**
  34387. * Begin a new frame
  34388. */
  34389. beginFrame(): void;
  34390. /**
  34391. * Enf the current frame
  34392. */
  34393. endFrame(): void;
  34394. /**
  34395. * Resize the view according to the canvas' size
  34396. */
  34397. resize(): void;
  34398. /**
  34399. * Force a specific size of the canvas
  34400. * @param width defines the new canvas' width
  34401. * @param height defines the new canvas' height
  34402. */
  34403. setSize(width: number, height: number): void;
  34404. /**
  34405. * Binds the frame buffer to the specified texture.
  34406. * @param texture The texture to render to or null for the default canvas
  34407. * @param faceIndex The face of the texture to render to in case of cube texture
  34408. * @param requiredWidth The width of the target to render to
  34409. * @param requiredHeight The height of the target to render to
  34410. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34411. * @param lodLevel defines the lod level to bind to the frame buffer
  34412. * @param layer defines the 2d array index to bind to frame buffer to
  34413. */
  34414. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34415. /** @hidden */
  34416. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34417. /**
  34418. * Unbind the current render target texture from the webGL context
  34419. * @param texture defines the render target texture to unbind
  34420. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34421. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34422. */
  34423. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34424. /**
  34425. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34426. */
  34427. flushFramebuffer(): void;
  34428. /**
  34429. * Unbind the current render target and bind the default framebuffer
  34430. */
  34431. restoreDefaultFramebuffer(): void;
  34432. /** @hidden */
  34433. protected _resetVertexBufferBinding(): void;
  34434. /**
  34435. * Creates a vertex buffer
  34436. * @param data the data for the vertex buffer
  34437. * @returns the new WebGL static buffer
  34438. */
  34439. createVertexBuffer(data: DataArray): DataBuffer;
  34440. private _createVertexBuffer;
  34441. /**
  34442. * Creates a dynamic vertex buffer
  34443. * @param data the data for the dynamic vertex buffer
  34444. * @returns the new WebGL dynamic buffer
  34445. */
  34446. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34447. protected _resetIndexBufferBinding(): void;
  34448. /**
  34449. * Creates a new index buffer
  34450. * @param indices defines the content of the index buffer
  34451. * @param updatable defines if the index buffer must be updatable
  34452. * @returns a new webGL buffer
  34453. */
  34454. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34455. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34456. /**
  34457. * Bind a webGL buffer to the webGL context
  34458. * @param buffer defines the buffer to bind
  34459. */
  34460. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34461. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34462. private bindBuffer;
  34463. /**
  34464. * update the bound buffer with the given data
  34465. * @param data defines the data to update
  34466. */
  34467. updateArrayBuffer(data: Float32Array): void;
  34468. private _vertexAttribPointer;
  34469. /** @hidden */
  34470. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34471. private _bindVertexBuffersAttributes;
  34472. /**
  34473. * Records a vertex array object
  34474. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34475. * @param vertexBuffers defines the list of vertex buffers to store
  34476. * @param indexBuffer defines the index buffer to store
  34477. * @param effect defines the effect to store
  34478. * @returns the new vertex array object
  34479. */
  34480. recordVertexArrayObject(vertexBuffers: {
  34481. [key: string]: VertexBuffer;
  34482. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34483. /**
  34484. * Bind a specific vertex array object
  34485. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34486. * @param vertexArrayObject defines the vertex array object to bind
  34487. * @param indexBuffer defines the index buffer to bind
  34488. */
  34489. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34490. /**
  34491. * Bind webGl buffers directly to the webGL context
  34492. * @param vertexBuffer defines the vertex buffer to bind
  34493. * @param indexBuffer defines the index buffer to bind
  34494. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34495. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34496. * @param effect defines the effect associated with the vertex buffer
  34497. */
  34498. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34499. private _unbindVertexArrayObject;
  34500. /**
  34501. * Bind a list of vertex buffers to the webGL context
  34502. * @param vertexBuffers defines the list of vertex buffers to bind
  34503. * @param indexBuffer defines the index buffer to bind
  34504. * @param effect defines the effect associated with the vertex buffers
  34505. */
  34506. bindBuffers(vertexBuffers: {
  34507. [key: string]: Nullable<VertexBuffer>;
  34508. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34509. /**
  34510. * Unbind all instance attributes
  34511. */
  34512. unbindInstanceAttributes(): void;
  34513. /**
  34514. * Release and free the memory of a vertex array object
  34515. * @param vao defines the vertex array object to delete
  34516. */
  34517. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34518. /** @hidden */
  34519. _releaseBuffer(buffer: DataBuffer): boolean;
  34520. protected _deleteBuffer(buffer: DataBuffer): void;
  34521. /**
  34522. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34523. * @param instancesBuffer defines the webGL buffer to update and bind
  34524. * @param data defines the data to store in the buffer
  34525. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34526. */
  34527. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34528. /**
  34529. * Bind the content of a webGL buffer used with instantiation
  34530. * @param instancesBuffer defines the webGL buffer to bind
  34531. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34532. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34533. */
  34534. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34535. /**
  34536. * Disable the instance attribute corresponding to the name in parameter
  34537. * @param name defines the name of the attribute to disable
  34538. */
  34539. disableInstanceAttributeByName(name: string): void;
  34540. /**
  34541. * Disable the instance attribute corresponding to the location in parameter
  34542. * @param attributeLocation defines the attribute location of the attribute to disable
  34543. */
  34544. disableInstanceAttribute(attributeLocation: number): void;
  34545. /**
  34546. * Disable the attribute corresponding to the location in parameter
  34547. * @param attributeLocation defines the attribute location of the attribute to disable
  34548. */
  34549. disableAttributeByIndex(attributeLocation: number): void;
  34550. /**
  34551. * Send a draw order
  34552. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34553. * @param indexStart defines the starting index
  34554. * @param indexCount defines the number of index to draw
  34555. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34556. */
  34557. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34558. /**
  34559. * Draw a list of points
  34560. * @param verticesStart defines the index of first vertex to draw
  34561. * @param verticesCount defines the count of vertices to draw
  34562. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34563. */
  34564. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34565. /**
  34566. * Draw a list of unindexed primitives
  34567. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34568. * @param verticesStart defines the index of first vertex to draw
  34569. * @param verticesCount defines the count of vertices to draw
  34570. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34571. */
  34572. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34573. /**
  34574. * Draw a list of indexed primitives
  34575. * @param fillMode defines the primitive to use
  34576. * @param indexStart defines the starting index
  34577. * @param indexCount defines the number of index to draw
  34578. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34579. */
  34580. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34581. /**
  34582. * Draw a list of unindexed primitives
  34583. * @param fillMode defines the primitive to use
  34584. * @param verticesStart defines the index of first vertex to draw
  34585. * @param verticesCount defines the count of vertices to draw
  34586. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34587. */
  34588. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34589. private _drawMode;
  34590. /** @hidden */
  34591. protected _reportDrawCall(): void;
  34592. /** @hidden */
  34593. _releaseEffect(effect: Effect): void;
  34594. /** @hidden */
  34595. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34596. /**
  34597. * Create a new effect (used to store vertex/fragment shaders)
  34598. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34599. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34600. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34601. * @param samplers defines an array of string used to represent textures
  34602. * @param defines defines the string containing the defines to use to compile the shaders
  34603. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34604. * @param onCompiled defines a function to call when the effect creation is successful
  34605. * @param onError defines a function to call when the effect creation has failed
  34606. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34607. * @returns the new Effect
  34608. */
  34609. 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;
  34610. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34611. private _compileShader;
  34612. private _compileRawShader;
  34613. /** @hidden */
  34614. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34615. /**
  34616. * Directly creates a webGL program
  34617. * @param pipelineContext defines the pipeline context to attach to
  34618. * @param vertexCode defines the vertex shader code to use
  34619. * @param fragmentCode defines the fragment shader code to use
  34620. * @param context defines the webGL context to use (if not set, the current one will be used)
  34621. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34622. * @returns the new webGL program
  34623. */
  34624. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34625. /**
  34626. * Creates a webGL program
  34627. * @param pipelineContext defines the pipeline context to attach to
  34628. * @param vertexCode defines the vertex shader code to use
  34629. * @param fragmentCode defines the fragment shader code to use
  34630. * @param defines defines the string containing the defines to use to compile the shaders
  34631. * @param context defines the webGL context to use (if not set, the current one will be used)
  34632. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34633. * @returns the new webGL program
  34634. */
  34635. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34636. /**
  34637. * Creates a new pipeline context
  34638. * @returns the new pipeline
  34639. */
  34640. createPipelineContext(): IPipelineContext;
  34641. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34642. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34643. /** @hidden */
  34644. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34645. /** @hidden */
  34646. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34647. /** @hidden */
  34648. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34649. /**
  34650. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34651. * @param pipelineContext defines the pipeline context to use
  34652. * @param uniformsNames defines the list of uniform names
  34653. * @returns an array of webGL uniform locations
  34654. */
  34655. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34656. /**
  34657. * Gets the lsit of active attributes for a given webGL program
  34658. * @param pipelineContext defines the pipeline context to use
  34659. * @param attributesNames defines the list of attribute names to get
  34660. * @returns an array of indices indicating the offset of each attribute
  34661. */
  34662. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34663. /**
  34664. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34665. * @param effect defines the effect to activate
  34666. */
  34667. enableEffect(effect: Nullable<Effect>): void;
  34668. /**
  34669. * Set the value of an uniform to a number (int)
  34670. * @param uniform defines the webGL uniform location where to store the value
  34671. * @param value defines the int number to store
  34672. */
  34673. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34674. /**
  34675. * Set the value of an uniform to an array of int32
  34676. * @param uniform defines the webGL uniform location where to store the value
  34677. * @param array defines the array of int32 to store
  34678. */
  34679. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34680. /**
  34681. * Set the value of an uniform to an array of int32 (stored as vec2)
  34682. * @param uniform defines the webGL uniform location where to store the value
  34683. * @param array defines the array of int32 to store
  34684. */
  34685. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34686. /**
  34687. * Set the value of an uniform to an array of int32 (stored as vec3)
  34688. * @param uniform defines the webGL uniform location where to store the value
  34689. * @param array defines the array of int32 to store
  34690. */
  34691. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34692. /**
  34693. * Set the value of an uniform to an array of int32 (stored as vec4)
  34694. * @param uniform defines the webGL uniform location where to store the value
  34695. * @param array defines the array of int32 to store
  34696. */
  34697. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34698. /**
  34699. * Set the value of an uniform to an array of number
  34700. * @param uniform defines the webGL uniform location where to store the value
  34701. * @param array defines the array of number to store
  34702. */
  34703. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34704. /**
  34705. * Set the value of an uniform to an array of number (stored as vec2)
  34706. * @param uniform defines the webGL uniform location where to store the value
  34707. * @param array defines the array of number to store
  34708. */
  34709. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34710. /**
  34711. * Set the value of an uniform to an array of number (stored as vec3)
  34712. * @param uniform defines the webGL uniform location where to store the value
  34713. * @param array defines the array of number to store
  34714. */
  34715. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34716. /**
  34717. * Set the value of an uniform to an array of number (stored as vec4)
  34718. * @param uniform defines the webGL uniform location where to store the value
  34719. * @param array defines the array of number to store
  34720. */
  34721. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34722. /**
  34723. * Set the value of an uniform to an array of float32 (stored as matrices)
  34724. * @param uniform defines the webGL uniform location where to store the value
  34725. * @param matrices defines the array of float32 to store
  34726. */
  34727. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34728. /**
  34729. * Set the value of an uniform to a matrix (3x3)
  34730. * @param uniform defines the webGL uniform location where to store the value
  34731. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34732. */
  34733. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34734. /**
  34735. * Set the value of an uniform to a matrix (2x2)
  34736. * @param uniform defines the webGL uniform location where to store the value
  34737. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34738. */
  34739. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34740. /**
  34741. * Set the value of an uniform to a number (float)
  34742. * @param uniform defines the webGL uniform location where to store the value
  34743. * @param value defines the float number to store
  34744. */
  34745. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34746. /**
  34747. * Set the value of an uniform to a vec2
  34748. * @param uniform defines the webGL uniform location where to store the value
  34749. * @param x defines the 1st component of the value
  34750. * @param y defines the 2nd component of the value
  34751. */
  34752. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34753. /**
  34754. * Set the value of an uniform to a vec3
  34755. * @param uniform defines the webGL uniform location where to store the value
  34756. * @param x defines the 1st component of the value
  34757. * @param y defines the 2nd component of the value
  34758. * @param z defines the 3rd component of the value
  34759. */
  34760. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34761. /**
  34762. * Set the value of an uniform to a vec4
  34763. * @param uniform defines the webGL uniform location where to store the value
  34764. * @param x defines the 1st component of the value
  34765. * @param y defines the 2nd component of the value
  34766. * @param z defines the 3rd component of the value
  34767. * @param w defines the 4th component of the value
  34768. */
  34769. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34770. /**
  34771. * Apply all cached states (depth, culling, stencil and alpha)
  34772. */
  34773. applyStates(): void;
  34774. /**
  34775. * Enable or disable color writing
  34776. * @param enable defines the state to set
  34777. */
  34778. setColorWrite(enable: boolean): void;
  34779. /**
  34780. * Gets a boolean indicating if color writing is enabled
  34781. * @returns the current color writing state
  34782. */
  34783. getColorWrite(): boolean;
  34784. /**
  34785. * Gets the depth culling state manager
  34786. */
  34787. get depthCullingState(): DepthCullingState;
  34788. /**
  34789. * Gets the alpha state manager
  34790. */
  34791. get alphaState(): AlphaState;
  34792. /**
  34793. * Gets the stencil state manager
  34794. */
  34795. get stencilState(): StencilState;
  34796. /**
  34797. * Clears the list of texture accessible through engine.
  34798. * This can help preventing texture load conflict due to name collision.
  34799. */
  34800. clearInternalTexturesCache(): void;
  34801. /**
  34802. * Force the entire cache to be cleared
  34803. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  34804. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  34805. */
  34806. wipeCaches(bruteForce?: boolean): void;
  34807. /** @hidden */
  34808. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  34809. min: number;
  34810. mag: number;
  34811. };
  34812. /** @hidden */
  34813. _createTexture(): WebGLTexture;
  34814. /**
  34815. * Usually called from Texture.ts.
  34816. * Passed information to create a WebGLTexture
  34817. * @param url defines a value which contains one of the following:
  34818. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  34819. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  34820. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  34821. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  34822. * @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)
  34823. * @param scene needed for loading to the correct scene
  34824. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  34825. * @param onLoad optional callback to be called upon successful completion
  34826. * @param onError optional callback to be called upon failure
  34827. * @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
  34828. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  34829. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  34830. * @param forcedExtension defines the extension to use to pick the right loader
  34831. * @param mimeType defines an optional mime type
  34832. * @returns a InternalTexture for assignment back into BABYLON.Texture
  34833. */
  34834. 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;
  34835. /**
  34836. * Loads an image as an HTMLImageElement.
  34837. * @param input url string, ArrayBuffer, or Blob to load
  34838. * @param onLoad callback called when the image successfully loads
  34839. * @param onError callback called when the image fails to load
  34840. * @param offlineProvider offline provider for caching
  34841. * @param mimeType optional mime type
  34842. * @returns the HTMLImageElement of the loaded image
  34843. * @hidden
  34844. */
  34845. 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>;
  34846. /**
  34847. * @hidden
  34848. */
  34849. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34850. private _unpackFlipYCached;
  34851. /**
  34852. * In case you are sharing the context with other applications, it might
  34853. * be interested to not cache the unpack flip y state to ensure a consistent
  34854. * value would be set.
  34855. */
  34856. enableUnpackFlipYCached: boolean;
  34857. /** @hidden */
  34858. _unpackFlipY(value: boolean): void;
  34859. /** @hidden */
  34860. _getUnpackAlignement(): number;
  34861. private _getTextureTarget;
  34862. /**
  34863. * Update the sampling mode of a given texture
  34864. * @param samplingMode defines the required sampling mode
  34865. * @param texture defines the texture to update
  34866. * @param generateMipMaps defines whether to generate mipmaps for the texture
  34867. */
  34868. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  34869. /**
  34870. * Update the sampling mode of a given texture
  34871. * @param texture defines the texture to update
  34872. * @param wrapU defines the texture wrap mode of the u coordinates
  34873. * @param wrapV defines the texture wrap mode of the v coordinates
  34874. * @param wrapR defines the texture wrap mode of the r coordinates
  34875. */
  34876. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  34877. /** @hidden */
  34878. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  34879. width: number;
  34880. height: number;
  34881. layers?: number;
  34882. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  34883. /** @hidden */
  34884. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34885. /** @hidden */
  34886. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  34887. /**
  34888. * Update a portion of an internal texture
  34889. * @param texture defines the texture to update
  34890. * @param imageData defines the data to store into the texture
  34891. * @param xOffset defines the x coordinates of the update rectangle
  34892. * @param yOffset defines the y coordinates of the update rectangle
  34893. * @param width defines the width of the update rectangle
  34894. * @param height defines the height of the update rectangle
  34895. * @param faceIndex defines the face index if texture is a cube (0 by default)
  34896. * @param lod defines the lod level to update (0 by default)
  34897. */
  34898. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  34899. /** @hidden */
  34900. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34901. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  34902. private _prepareWebGLTexture;
  34903. /** @hidden */
  34904. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  34905. private _getDepthStencilBuffer;
  34906. /** @hidden */
  34907. _releaseFramebufferObjects(texture: InternalTexture): void;
  34908. /** @hidden */
  34909. _releaseTexture(texture: InternalTexture): void;
  34910. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  34911. protected _setProgram(program: WebGLProgram): void;
  34912. protected _boundUniforms: {
  34913. [key: number]: WebGLUniformLocation;
  34914. };
  34915. /**
  34916. * Binds an effect to the webGL context
  34917. * @param effect defines the effect to bind
  34918. */
  34919. bindSamplers(effect: Effect): void;
  34920. private _activateCurrentTexture;
  34921. /** @hidden */
  34922. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  34923. /** @hidden */
  34924. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  34925. /**
  34926. * Unbind all textures from the webGL context
  34927. */
  34928. unbindAllTextures(): void;
  34929. /**
  34930. * Sets a texture to the according uniform.
  34931. * @param channel The texture channel
  34932. * @param uniform The uniform to set
  34933. * @param texture The texture to apply
  34934. */
  34935. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  34936. private _bindSamplerUniformToChannel;
  34937. private _getTextureWrapMode;
  34938. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  34939. /**
  34940. * Sets an array of texture to the webGL context
  34941. * @param channel defines the channel where the texture array must be set
  34942. * @param uniform defines the associated uniform location
  34943. * @param textures defines the array of textures to bind
  34944. */
  34945. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  34946. /** @hidden */
  34947. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  34948. private _setTextureParameterFloat;
  34949. private _setTextureParameterInteger;
  34950. /**
  34951. * Unbind all vertex attributes from the webGL context
  34952. */
  34953. unbindAllAttributes(): void;
  34954. /**
  34955. * 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
  34956. */
  34957. releaseEffects(): void;
  34958. /**
  34959. * Dispose and release all associated resources
  34960. */
  34961. dispose(): void;
  34962. /**
  34963. * Attach a new callback raised when context lost event is fired
  34964. * @param callback defines the callback to call
  34965. */
  34966. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  34967. /**
  34968. * Attach a new callback raised when context restored event is fired
  34969. * @param callback defines the callback to call
  34970. */
  34971. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  34972. /**
  34973. * Get the current error code of the webGL context
  34974. * @returns the error code
  34975. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34976. */
  34977. getError(): number;
  34978. private _canRenderToFloatFramebuffer;
  34979. private _canRenderToHalfFloatFramebuffer;
  34980. private _canRenderToFramebuffer;
  34981. /** @hidden */
  34982. _getWebGLTextureType(type: number): number;
  34983. /** @hidden */
  34984. _getInternalFormat(format: number): number;
  34985. /** @hidden */
  34986. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  34987. /** @hidden */
  34988. _getRGBAMultiSampleBufferFormat(type: number): number;
  34989. /** @hidden */
  34990. _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;
  34991. /**
  34992. * Loads a file from a url
  34993. * @param url url to load
  34994. * @param onSuccess callback called when the file successfully loads
  34995. * @param onProgress callback called while file is loading (if the server supports this mode)
  34996. * @param offlineProvider defines the offline provider for caching
  34997. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34998. * @param onError callback called when the file fails to load
  34999. * @returns a file request object
  35000. * @hidden
  35001. */
  35002. 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;
  35003. /**
  35004. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35005. * @param x defines the x coordinate of the rectangle where pixels must be read
  35006. * @param y defines the y coordinate of the rectangle where pixels must be read
  35007. * @param width defines the width of the rectangle where pixels must be read
  35008. * @param height defines the height of the rectangle where pixels must be read
  35009. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35010. * @returns a Uint8Array containing RGBA colors
  35011. */
  35012. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35013. private static _isSupported;
  35014. /**
  35015. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35016. * @returns true if the engine can be created
  35017. * @ignorenaming
  35018. */
  35019. static isSupported(): boolean;
  35020. /**
  35021. * Find the next highest power of two.
  35022. * @param x Number to start search from.
  35023. * @return Next highest power of two.
  35024. */
  35025. static CeilingPOT(x: number): number;
  35026. /**
  35027. * Find the next lowest power of two.
  35028. * @param x Number to start search from.
  35029. * @return Next lowest power of two.
  35030. */
  35031. static FloorPOT(x: number): number;
  35032. /**
  35033. * Find the nearest power of two.
  35034. * @param x Number to start search from.
  35035. * @return Next nearest power of two.
  35036. */
  35037. static NearestPOT(x: number): number;
  35038. /**
  35039. * Get the closest exponent of two
  35040. * @param value defines the value to approximate
  35041. * @param max defines the maximum value to return
  35042. * @param mode defines how to define the closest value
  35043. * @returns closest exponent of two of the given value
  35044. */
  35045. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35046. /**
  35047. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35048. * @param func - the function to be called
  35049. * @param requester - the object that will request the next frame. Falls back to window.
  35050. * @returns frame number
  35051. */
  35052. static QueueNewFrame(func: () => void, requester?: any): number;
  35053. /**
  35054. * Gets host document
  35055. * @returns the host document object
  35056. */
  35057. getHostDocument(): Nullable<Document>;
  35058. }
  35059. }
  35060. declare module BABYLON {
  35061. /**
  35062. * Class representing spherical harmonics coefficients to the 3rd degree
  35063. */
  35064. export class SphericalHarmonics {
  35065. /**
  35066. * Defines whether or not the harmonics have been prescaled for rendering.
  35067. */
  35068. preScaled: boolean;
  35069. /**
  35070. * The l0,0 coefficients of the spherical harmonics
  35071. */
  35072. l00: Vector3;
  35073. /**
  35074. * The l1,-1 coefficients of the spherical harmonics
  35075. */
  35076. l1_1: Vector3;
  35077. /**
  35078. * The l1,0 coefficients of the spherical harmonics
  35079. */
  35080. l10: Vector3;
  35081. /**
  35082. * The l1,1 coefficients of the spherical harmonics
  35083. */
  35084. l11: Vector3;
  35085. /**
  35086. * The l2,-2 coefficients of the spherical harmonics
  35087. */
  35088. l2_2: Vector3;
  35089. /**
  35090. * The l2,-1 coefficients of the spherical harmonics
  35091. */
  35092. l2_1: Vector3;
  35093. /**
  35094. * The l2,0 coefficients of the spherical harmonics
  35095. */
  35096. l20: Vector3;
  35097. /**
  35098. * The l2,1 coefficients of the spherical harmonics
  35099. */
  35100. l21: Vector3;
  35101. /**
  35102. * The l2,2 coefficients of the spherical harmonics
  35103. */
  35104. l22: Vector3;
  35105. /**
  35106. * Adds a light to the spherical harmonics
  35107. * @param direction the direction of the light
  35108. * @param color the color of the light
  35109. * @param deltaSolidAngle the delta solid angle of the light
  35110. */
  35111. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35112. /**
  35113. * Scales the spherical harmonics by the given amount
  35114. * @param scale the amount to scale
  35115. */
  35116. scaleInPlace(scale: number): void;
  35117. /**
  35118. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35119. *
  35120. * ```
  35121. * E_lm = A_l * L_lm
  35122. * ```
  35123. *
  35124. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35125. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35126. * the scaling factors are given in equation 9.
  35127. */
  35128. convertIncidentRadianceToIrradiance(): void;
  35129. /**
  35130. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35131. *
  35132. * ```
  35133. * L = (1/pi) * E * rho
  35134. * ```
  35135. *
  35136. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35137. */
  35138. convertIrradianceToLambertianRadiance(): void;
  35139. /**
  35140. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35141. * required operations at run time.
  35142. *
  35143. * This is simply done by scaling back the SH with Ylm constants parameter.
  35144. * The trigonometric part being applied by the shader at run time.
  35145. */
  35146. preScaleForRendering(): void;
  35147. /**
  35148. * Constructs a spherical harmonics from an array.
  35149. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35150. * @returns the spherical harmonics
  35151. */
  35152. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35153. /**
  35154. * Gets the spherical harmonics from polynomial
  35155. * @param polynomial the spherical polynomial
  35156. * @returns the spherical harmonics
  35157. */
  35158. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35159. }
  35160. /**
  35161. * Class representing spherical polynomial coefficients to the 3rd degree
  35162. */
  35163. export class SphericalPolynomial {
  35164. private _harmonics;
  35165. /**
  35166. * The spherical harmonics used to create the polynomials.
  35167. */
  35168. get preScaledHarmonics(): SphericalHarmonics;
  35169. /**
  35170. * The x coefficients of the spherical polynomial
  35171. */
  35172. x: Vector3;
  35173. /**
  35174. * The y coefficients of the spherical polynomial
  35175. */
  35176. y: Vector3;
  35177. /**
  35178. * The z coefficients of the spherical polynomial
  35179. */
  35180. z: Vector3;
  35181. /**
  35182. * The xx coefficients of the spherical polynomial
  35183. */
  35184. xx: Vector3;
  35185. /**
  35186. * The yy coefficients of the spherical polynomial
  35187. */
  35188. yy: Vector3;
  35189. /**
  35190. * The zz coefficients of the spherical polynomial
  35191. */
  35192. zz: Vector3;
  35193. /**
  35194. * The xy coefficients of the spherical polynomial
  35195. */
  35196. xy: Vector3;
  35197. /**
  35198. * The yz coefficients of the spherical polynomial
  35199. */
  35200. yz: Vector3;
  35201. /**
  35202. * The zx coefficients of the spherical polynomial
  35203. */
  35204. zx: Vector3;
  35205. /**
  35206. * Adds an ambient color to the spherical polynomial
  35207. * @param color the color to add
  35208. */
  35209. addAmbient(color: Color3): void;
  35210. /**
  35211. * Scales the spherical polynomial by the given amount
  35212. * @param scale the amount to scale
  35213. */
  35214. scaleInPlace(scale: number): void;
  35215. /**
  35216. * Gets the spherical polynomial from harmonics
  35217. * @param harmonics the spherical harmonics
  35218. * @returns the spherical polynomial
  35219. */
  35220. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35221. /**
  35222. * Constructs a spherical polynomial from an array.
  35223. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35224. * @returns the spherical polynomial
  35225. */
  35226. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35227. }
  35228. }
  35229. declare module BABYLON {
  35230. /**
  35231. * Defines the source of the internal texture
  35232. */
  35233. export enum InternalTextureSource {
  35234. /**
  35235. * The source of the texture data is unknown
  35236. */
  35237. Unknown = 0,
  35238. /**
  35239. * Texture data comes from an URL
  35240. */
  35241. Url = 1,
  35242. /**
  35243. * Texture data is only used for temporary storage
  35244. */
  35245. Temp = 2,
  35246. /**
  35247. * Texture data comes from raw data (ArrayBuffer)
  35248. */
  35249. Raw = 3,
  35250. /**
  35251. * Texture content is dynamic (video or dynamic texture)
  35252. */
  35253. Dynamic = 4,
  35254. /**
  35255. * Texture content is generated by rendering to it
  35256. */
  35257. RenderTarget = 5,
  35258. /**
  35259. * Texture content is part of a multi render target process
  35260. */
  35261. MultiRenderTarget = 6,
  35262. /**
  35263. * Texture data comes from a cube data file
  35264. */
  35265. Cube = 7,
  35266. /**
  35267. * Texture data comes from a raw cube data
  35268. */
  35269. CubeRaw = 8,
  35270. /**
  35271. * Texture data come from a prefiltered cube data file
  35272. */
  35273. CubePrefiltered = 9,
  35274. /**
  35275. * Texture content is raw 3D data
  35276. */
  35277. Raw3D = 10,
  35278. /**
  35279. * Texture content is raw 2D array data
  35280. */
  35281. Raw2DArray = 11,
  35282. /**
  35283. * Texture content is a depth texture
  35284. */
  35285. Depth = 12,
  35286. /**
  35287. * Texture data comes from a raw cube data encoded with RGBD
  35288. */
  35289. CubeRawRGBD = 13
  35290. }
  35291. /**
  35292. * Class used to store data associated with WebGL texture data for the engine
  35293. * This class should not be used directly
  35294. */
  35295. export class InternalTexture {
  35296. /** @hidden */
  35297. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35298. /**
  35299. * Defines if the texture is ready
  35300. */
  35301. isReady: boolean;
  35302. /**
  35303. * Defines if the texture is a cube texture
  35304. */
  35305. isCube: boolean;
  35306. /**
  35307. * Defines if the texture contains 3D data
  35308. */
  35309. is3D: boolean;
  35310. /**
  35311. * Defines if the texture contains 2D array data
  35312. */
  35313. is2DArray: boolean;
  35314. /**
  35315. * Defines if the texture contains multiview data
  35316. */
  35317. isMultiview: boolean;
  35318. /**
  35319. * Gets the URL used to load this texture
  35320. */
  35321. url: string;
  35322. /**
  35323. * Gets the sampling mode of the texture
  35324. */
  35325. samplingMode: number;
  35326. /**
  35327. * Gets a boolean indicating if the texture needs mipmaps generation
  35328. */
  35329. generateMipMaps: boolean;
  35330. /**
  35331. * Gets the number of samples used by the texture (WebGL2+ only)
  35332. */
  35333. samples: number;
  35334. /**
  35335. * Gets the type of the texture (int, float...)
  35336. */
  35337. type: number;
  35338. /**
  35339. * Gets the format of the texture (RGB, RGBA...)
  35340. */
  35341. format: number;
  35342. /**
  35343. * Observable called when the texture is loaded
  35344. */
  35345. onLoadedObservable: Observable<InternalTexture>;
  35346. /**
  35347. * Gets the width of the texture
  35348. */
  35349. width: number;
  35350. /**
  35351. * Gets the height of the texture
  35352. */
  35353. height: number;
  35354. /**
  35355. * Gets the depth of the texture
  35356. */
  35357. depth: number;
  35358. /**
  35359. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35360. */
  35361. baseWidth: number;
  35362. /**
  35363. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35364. */
  35365. baseHeight: number;
  35366. /**
  35367. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35368. */
  35369. baseDepth: number;
  35370. /**
  35371. * Gets a boolean indicating if the texture is inverted on Y axis
  35372. */
  35373. invertY: boolean;
  35374. /** @hidden */
  35375. _invertVScale: boolean;
  35376. /** @hidden */
  35377. _associatedChannel: number;
  35378. /** @hidden */
  35379. _source: InternalTextureSource;
  35380. /** @hidden */
  35381. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35382. /** @hidden */
  35383. _bufferView: Nullable<ArrayBufferView>;
  35384. /** @hidden */
  35385. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35386. /** @hidden */
  35387. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35388. /** @hidden */
  35389. _size: number;
  35390. /** @hidden */
  35391. _extension: string;
  35392. /** @hidden */
  35393. _files: Nullable<string[]>;
  35394. /** @hidden */
  35395. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35396. /** @hidden */
  35397. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35398. /** @hidden */
  35399. _framebuffer: Nullable<WebGLFramebuffer>;
  35400. /** @hidden */
  35401. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35402. /** @hidden */
  35403. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35404. /** @hidden */
  35405. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35406. /** @hidden */
  35407. _attachments: Nullable<number[]>;
  35408. /** @hidden */
  35409. _cachedCoordinatesMode: Nullable<number>;
  35410. /** @hidden */
  35411. _cachedWrapU: Nullable<number>;
  35412. /** @hidden */
  35413. _cachedWrapV: Nullable<number>;
  35414. /** @hidden */
  35415. _cachedWrapR: Nullable<number>;
  35416. /** @hidden */
  35417. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35418. /** @hidden */
  35419. _isDisabled: boolean;
  35420. /** @hidden */
  35421. _compression: Nullable<string>;
  35422. /** @hidden */
  35423. _generateStencilBuffer: boolean;
  35424. /** @hidden */
  35425. _generateDepthBuffer: boolean;
  35426. /** @hidden */
  35427. _comparisonFunction: number;
  35428. /** @hidden */
  35429. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35430. /** @hidden */
  35431. _lodGenerationScale: number;
  35432. /** @hidden */
  35433. _lodGenerationOffset: number;
  35434. /** @hidden */
  35435. _depthStencilTexture: Nullable<InternalTexture>;
  35436. /** @hidden */
  35437. _colorTextureArray: Nullable<WebGLTexture>;
  35438. /** @hidden */
  35439. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35440. /** @hidden */
  35441. _lodTextureHigh: Nullable<BaseTexture>;
  35442. /** @hidden */
  35443. _lodTextureMid: Nullable<BaseTexture>;
  35444. /** @hidden */
  35445. _lodTextureLow: Nullable<BaseTexture>;
  35446. /** @hidden */
  35447. _isRGBD: boolean;
  35448. /** @hidden */
  35449. _linearSpecularLOD: boolean;
  35450. /** @hidden */
  35451. _irradianceTexture: Nullable<BaseTexture>;
  35452. /** @hidden */
  35453. _webGLTexture: Nullable<WebGLTexture>;
  35454. /** @hidden */
  35455. _references: number;
  35456. private _engine;
  35457. /**
  35458. * Gets the Engine the texture belongs to.
  35459. * @returns The babylon engine
  35460. */
  35461. getEngine(): ThinEngine;
  35462. /**
  35463. * Gets the data source type of the texture
  35464. */
  35465. get source(): InternalTextureSource;
  35466. /**
  35467. * Creates a new InternalTexture
  35468. * @param engine defines the engine to use
  35469. * @param source defines the type of data that will be used
  35470. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35471. */
  35472. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35473. /**
  35474. * Increments the number of references (ie. the number of Texture that point to it)
  35475. */
  35476. incrementReferences(): void;
  35477. /**
  35478. * Change the size of the texture (not the size of the content)
  35479. * @param width defines the new width
  35480. * @param height defines the new height
  35481. * @param depth defines the new depth (1 by default)
  35482. */
  35483. updateSize(width: int, height: int, depth?: int): void;
  35484. /** @hidden */
  35485. _rebuild(): void;
  35486. /** @hidden */
  35487. _swapAndDie(target: InternalTexture): void;
  35488. /**
  35489. * Dispose the current allocated resources
  35490. */
  35491. dispose(): void;
  35492. }
  35493. }
  35494. declare module BABYLON {
  35495. /**
  35496. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35497. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35498. */
  35499. export class Analyser {
  35500. /**
  35501. * Gets or sets the smoothing
  35502. * @ignorenaming
  35503. */
  35504. SMOOTHING: number;
  35505. /**
  35506. * Gets or sets the FFT table size
  35507. * @ignorenaming
  35508. */
  35509. FFT_SIZE: number;
  35510. /**
  35511. * Gets or sets the bar graph amplitude
  35512. * @ignorenaming
  35513. */
  35514. BARGRAPHAMPLITUDE: number;
  35515. /**
  35516. * Gets or sets the position of the debug canvas
  35517. * @ignorenaming
  35518. */
  35519. DEBUGCANVASPOS: {
  35520. x: number;
  35521. y: number;
  35522. };
  35523. /**
  35524. * Gets or sets the debug canvas size
  35525. * @ignorenaming
  35526. */
  35527. DEBUGCANVASSIZE: {
  35528. width: number;
  35529. height: number;
  35530. };
  35531. private _byteFreqs;
  35532. private _byteTime;
  35533. private _floatFreqs;
  35534. private _webAudioAnalyser;
  35535. private _debugCanvas;
  35536. private _debugCanvasContext;
  35537. private _scene;
  35538. private _registerFunc;
  35539. private _audioEngine;
  35540. /**
  35541. * Creates a new analyser
  35542. * @param scene defines hosting scene
  35543. */
  35544. constructor(scene: Scene);
  35545. /**
  35546. * Get the number of data values you will have to play with for the visualization
  35547. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35548. * @returns a number
  35549. */
  35550. getFrequencyBinCount(): number;
  35551. /**
  35552. * Gets the current frequency data as a byte array
  35553. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35554. * @returns a Uint8Array
  35555. */
  35556. getByteFrequencyData(): Uint8Array;
  35557. /**
  35558. * Gets the current waveform as a byte array
  35559. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35560. * @returns a Uint8Array
  35561. */
  35562. getByteTimeDomainData(): Uint8Array;
  35563. /**
  35564. * Gets the current frequency data as a float array
  35565. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35566. * @returns a Float32Array
  35567. */
  35568. getFloatFrequencyData(): Float32Array;
  35569. /**
  35570. * Renders the debug canvas
  35571. */
  35572. drawDebugCanvas(): void;
  35573. /**
  35574. * Stops rendering the debug canvas and removes it
  35575. */
  35576. stopDebugCanvas(): void;
  35577. /**
  35578. * Connects two audio nodes
  35579. * @param inputAudioNode defines first node to connect
  35580. * @param outputAudioNode defines second node to connect
  35581. */
  35582. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35583. /**
  35584. * Releases all associated resources
  35585. */
  35586. dispose(): void;
  35587. }
  35588. }
  35589. declare module BABYLON {
  35590. /**
  35591. * This represents an audio engine and it is responsible
  35592. * to play, synchronize and analyse sounds throughout the application.
  35593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35594. */
  35595. export interface IAudioEngine extends IDisposable {
  35596. /**
  35597. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35598. */
  35599. readonly canUseWebAudio: boolean;
  35600. /**
  35601. * Gets the current AudioContext if available.
  35602. */
  35603. readonly audioContext: Nullable<AudioContext>;
  35604. /**
  35605. * The master gain node defines the global audio volume of your audio engine.
  35606. */
  35607. readonly masterGain: GainNode;
  35608. /**
  35609. * Gets whether or not mp3 are supported by your browser.
  35610. */
  35611. readonly isMP3supported: boolean;
  35612. /**
  35613. * Gets whether or not ogg are supported by your browser.
  35614. */
  35615. readonly isOGGsupported: boolean;
  35616. /**
  35617. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35618. * @ignoreNaming
  35619. */
  35620. WarnedWebAudioUnsupported: boolean;
  35621. /**
  35622. * Defines if the audio engine relies on a custom unlocked button.
  35623. * In this case, the embedded button will not be displayed.
  35624. */
  35625. useCustomUnlockedButton: boolean;
  35626. /**
  35627. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35628. */
  35629. readonly unlocked: boolean;
  35630. /**
  35631. * Event raised when audio has been unlocked on the browser.
  35632. */
  35633. onAudioUnlockedObservable: Observable<AudioEngine>;
  35634. /**
  35635. * Event raised when audio has been locked on the browser.
  35636. */
  35637. onAudioLockedObservable: Observable<AudioEngine>;
  35638. /**
  35639. * Flags the audio engine in Locked state.
  35640. * This happens due to new browser policies preventing audio to autoplay.
  35641. */
  35642. lock(): void;
  35643. /**
  35644. * Unlocks the audio engine once a user action has been done on the dom.
  35645. * This is helpful to resume play once browser policies have been satisfied.
  35646. */
  35647. unlock(): void;
  35648. /**
  35649. * Gets the global volume sets on the master gain.
  35650. * @returns the global volume if set or -1 otherwise
  35651. */
  35652. getGlobalVolume(): number;
  35653. /**
  35654. * Sets the global volume of your experience (sets on the master gain).
  35655. * @param newVolume Defines the new global volume of the application
  35656. */
  35657. setGlobalVolume(newVolume: number): void;
  35658. /**
  35659. * Connect the audio engine to an audio analyser allowing some amazing
  35660. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35662. * @param analyser The analyser to connect to the engine
  35663. */
  35664. connectToAnalyser(analyser: Analyser): void;
  35665. }
  35666. /**
  35667. * This represents the default audio engine used in babylon.
  35668. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35669. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35670. */
  35671. export class AudioEngine implements IAudioEngine {
  35672. private _audioContext;
  35673. private _audioContextInitialized;
  35674. private _muteButton;
  35675. private _hostElement;
  35676. /**
  35677. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35678. */
  35679. canUseWebAudio: boolean;
  35680. /**
  35681. * The master gain node defines the global audio volume of your audio engine.
  35682. */
  35683. masterGain: GainNode;
  35684. /**
  35685. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35686. * @ignoreNaming
  35687. */
  35688. WarnedWebAudioUnsupported: boolean;
  35689. /**
  35690. * Gets whether or not mp3 are supported by your browser.
  35691. */
  35692. isMP3supported: boolean;
  35693. /**
  35694. * Gets whether or not ogg are supported by your browser.
  35695. */
  35696. isOGGsupported: boolean;
  35697. /**
  35698. * Gets whether audio has been unlocked on the device.
  35699. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35700. * a user interaction has happened.
  35701. */
  35702. unlocked: boolean;
  35703. /**
  35704. * Defines if the audio engine relies on a custom unlocked button.
  35705. * In this case, the embedded button will not be displayed.
  35706. */
  35707. useCustomUnlockedButton: boolean;
  35708. /**
  35709. * Event raised when audio has been unlocked on the browser.
  35710. */
  35711. onAudioUnlockedObservable: Observable<AudioEngine>;
  35712. /**
  35713. * Event raised when audio has been locked on the browser.
  35714. */
  35715. onAudioLockedObservable: Observable<AudioEngine>;
  35716. /**
  35717. * Gets the current AudioContext if available.
  35718. */
  35719. get audioContext(): Nullable<AudioContext>;
  35720. private _connectedAnalyser;
  35721. /**
  35722. * Instantiates a new audio engine.
  35723. *
  35724. * There should be only one per page as some browsers restrict the number
  35725. * of audio contexts you can create.
  35726. * @param hostElement defines the host element where to display the mute icon if necessary
  35727. */
  35728. constructor(hostElement?: Nullable<HTMLElement>);
  35729. /**
  35730. * Flags the audio engine in Locked state.
  35731. * This happens due to new browser policies preventing audio to autoplay.
  35732. */
  35733. lock(): void;
  35734. /**
  35735. * Unlocks the audio engine once a user action has been done on the dom.
  35736. * This is helpful to resume play once browser policies have been satisfied.
  35737. */
  35738. unlock(): void;
  35739. private _resumeAudioContext;
  35740. private _initializeAudioContext;
  35741. private _tryToRun;
  35742. private _triggerRunningState;
  35743. private _triggerSuspendedState;
  35744. private _displayMuteButton;
  35745. private _moveButtonToTopLeft;
  35746. private _onResize;
  35747. private _hideMuteButton;
  35748. /**
  35749. * Destroy and release the resources associated with the audio ccontext.
  35750. */
  35751. dispose(): void;
  35752. /**
  35753. * Gets the global volume sets on the master gain.
  35754. * @returns the global volume if set or -1 otherwise
  35755. */
  35756. getGlobalVolume(): number;
  35757. /**
  35758. * Sets the global volume of your experience (sets on the master gain).
  35759. * @param newVolume Defines the new global volume of the application
  35760. */
  35761. setGlobalVolume(newVolume: number): void;
  35762. /**
  35763. * Connect the audio engine to an audio analyser allowing some amazing
  35764. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35766. * @param analyser The analyser to connect to the engine
  35767. */
  35768. connectToAnalyser(analyser: Analyser): void;
  35769. }
  35770. }
  35771. declare module BABYLON {
  35772. /**
  35773. * Interface used to present a loading screen while loading a scene
  35774. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35775. */
  35776. export interface ILoadingScreen {
  35777. /**
  35778. * Function called to display the loading screen
  35779. */
  35780. displayLoadingUI: () => void;
  35781. /**
  35782. * Function called to hide the loading screen
  35783. */
  35784. hideLoadingUI: () => void;
  35785. /**
  35786. * Gets or sets the color to use for the background
  35787. */
  35788. loadingUIBackgroundColor: string;
  35789. /**
  35790. * Gets or sets the text to display while loading
  35791. */
  35792. loadingUIText: string;
  35793. }
  35794. /**
  35795. * Class used for the default loading screen
  35796. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35797. */
  35798. export class DefaultLoadingScreen implements ILoadingScreen {
  35799. private _renderingCanvas;
  35800. private _loadingText;
  35801. private _loadingDivBackgroundColor;
  35802. private _loadingDiv;
  35803. private _loadingTextDiv;
  35804. /** Gets or sets the logo url to use for the default loading screen */
  35805. static DefaultLogoUrl: string;
  35806. /** Gets or sets the spinner url to use for the default loading screen */
  35807. static DefaultSpinnerUrl: string;
  35808. /**
  35809. * Creates a new default loading screen
  35810. * @param _renderingCanvas defines the canvas used to render the scene
  35811. * @param _loadingText defines the default text to display
  35812. * @param _loadingDivBackgroundColor defines the default background color
  35813. */
  35814. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  35815. /**
  35816. * Function called to display the loading screen
  35817. */
  35818. displayLoadingUI(): void;
  35819. /**
  35820. * Function called to hide the loading screen
  35821. */
  35822. hideLoadingUI(): void;
  35823. /**
  35824. * Gets or sets the text to display while loading
  35825. */
  35826. set loadingUIText(text: string);
  35827. get loadingUIText(): string;
  35828. /**
  35829. * Gets or sets the color to use for the background
  35830. */
  35831. get loadingUIBackgroundColor(): string;
  35832. set loadingUIBackgroundColor(color: string);
  35833. private _resizeLoadingUI;
  35834. }
  35835. }
  35836. declare module BABYLON {
  35837. /**
  35838. * Interface for any object that can request an animation frame
  35839. */
  35840. export interface ICustomAnimationFrameRequester {
  35841. /**
  35842. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  35843. */
  35844. renderFunction?: Function;
  35845. /**
  35846. * Called to request the next frame to render to
  35847. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  35848. */
  35849. requestAnimationFrame: Function;
  35850. /**
  35851. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  35852. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  35853. */
  35854. requestID?: number;
  35855. }
  35856. }
  35857. declare module BABYLON {
  35858. /**
  35859. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  35860. */
  35861. export class PerformanceMonitor {
  35862. private _enabled;
  35863. private _rollingFrameTime;
  35864. private _lastFrameTimeMs;
  35865. /**
  35866. * constructor
  35867. * @param frameSampleSize The number of samples required to saturate the sliding window
  35868. */
  35869. constructor(frameSampleSize?: number);
  35870. /**
  35871. * Samples current frame
  35872. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  35873. */
  35874. sampleFrame(timeMs?: number): void;
  35875. /**
  35876. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35877. */
  35878. get averageFrameTime(): number;
  35879. /**
  35880. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35881. */
  35882. get averageFrameTimeVariance(): number;
  35883. /**
  35884. * Returns the frame time of the most recent frame
  35885. */
  35886. get instantaneousFrameTime(): number;
  35887. /**
  35888. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  35889. */
  35890. get averageFPS(): number;
  35891. /**
  35892. * Returns the average framerate in frames per second using the most recent frame time
  35893. */
  35894. get instantaneousFPS(): number;
  35895. /**
  35896. * Returns true if enough samples have been taken to completely fill the sliding window
  35897. */
  35898. get isSaturated(): boolean;
  35899. /**
  35900. * Enables contributions to the sliding window sample set
  35901. */
  35902. enable(): void;
  35903. /**
  35904. * Disables contributions to the sliding window sample set
  35905. * Samples will not be interpolated over the disabled period
  35906. */
  35907. disable(): void;
  35908. /**
  35909. * Returns true if sampling is enabled
  35910. */
  35911. get isEnabled(): boolean;
  35912. /**
  35913. * Resets performance monitor
  35914. */
  35915. reset(): void;
  35916. }
  35917. /**
  35918. * RollingAverage
  35919. *
  35920. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  35921. */
  35922. export class RollingAverage {
  35923. /**
  35924. * Current average
  35925. */
  35926. average: number;
  35927. /**
  35928. * Current variance
  35929. */
  35930. variance: number;
  35931. protected _samples: Array<number>;
  35932. protected _sampleCount: number;
  35933. protected _pos: number;
  35934. protected _m2: number;
  35935. /**
  35936. * constructor
  35937. * @param length The number of samples required to saturate the sliding window
  35938. */
  35939. constructor(length: number);
  35940. /**
  35941. * Adds a sample to the sample set
  35942. * @param v The sample value
  35943. */
  35944. add(v: number): void;
  35945. /**
  35946. * Returns previously added values or null if outside of history or outside the sliding window domain
  35947. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  35948. * @return Value previously recorded with add() or null if outside of range
  35949. */
  35950. history(i: number): number;
  35951. /**
  35952. * Returns true if enough samples have been taken to completely fill the sliding window
  35953. * @return true if sample-set saturated
  35954. */
  35955. isSaturated(): boolean;
  35956. /**
  35957. * Resets the rolling average (equivalent to 0 samples taken so far)
  35958. */
  35959. reset(): void;
  35960. /**
  35961. * Wraps a value around the sample range boundaries
  35962. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  35963. * @return Wrapped position in sample range
  35964. */
  35965. protected _wrapPosition(i: number): number;
  35966. }
  35967. }
  35968. declare module BABYLON {
  35969. /**
  35970. * This class is used to track a performance counter which is number based.
  35971. * The user has access to many properties which give statistics of different nature.
  35972. *
  35973. * The implementer can track two kinds of Performance Counter: time and count.
  35974. * 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.
  35975. * 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.
  35976. */
  35977. export class PerfCounter {
  35978. /**
  35979. * Gets or sets a global boolean to turn on and off all the counters
  35980. */
  35981. static Enabled: boolean;
  35982. /**
  35983. * Returns the smallest value ever
  35984. */
  35985. get min(): number;
  35986. /**
  35987. * Returns the biggest value ever
  35988. */
  35989. get max(): number;
  35990. /**
  35991. * Returns the average value since the performance counter is running
  35992. */
  35993. get average(): number;
  35994. /**
  35995. * Returns the average value of the last second the counter was monitored
  35996. */
  35997. get lastSecAverage(): number;
  35998. /**
  35999. * Returns the current value
  36000. */
  36001. get current(): number;
  36002. /**
  36003. * Gets the accumulated total
  36004. */
  36005. get total(): number;
  36006. /**
  36007. * Gets the total value count
  36008. */
  36009. get count(): number;
  36010. /**
  36011. * Creates a new counter
  36012. */
  36013. constructor();
  36014. /**
  36015. * Call this method to start monitoring a new frame.
  36016. * 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.
  36017. */
  36018. fetchNewFrame(): void;
  36019. /**
  36020. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36021. * @param newCount the count value to add to the monitored count
  36022. * @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.
  36023. */
  36024. addCount(newCount: number, fetchResult: boolean): void;
  36025. /**
  36026. * Start monitoring this performance counter
  36027. */
  36028. beginMonitoring(): void;
  36029. /**
  36030. * Compute the time lapsed since the previous beginMonitoring() call.
  36031. * @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
  36032. */
  36033. endMonitoring(newFrame?: boolean): void;
  36034. private _fetchResult;
  36035. private _startMonitoringTime;
  36036. private _min;
  36037. private _max;
  36038. private _average;
  36039. private _current;
  36040. private _totalValueCount;
  36041. private _totalAccumulated;
  36042. private _lastSecAverage;
  36043. private _lastSecAccumulated;
  36044. private _lastSecTime;
  36045. private _lastSecValueCount;
  36046. }
  36047. }
  36048. declare module BABYLON {
  36049. interface ThinEngine {
  36050. /**
  36051. * Sets alpha constants used by some alpha blending modes
  36052. * @param r defines the red component
  36053. * @param g defines the green component
  36054. * @param b defines the blue component
  36055. * @param a defines the alpha component
  36056. */
  36057. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36058. /**
  36059. * Sets the current alpha mode
  36060. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36061. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36062. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36063. */
  36064. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36065. /**
  36066. * Gets the current alpha mode
  36067. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36068. * @returns the current alpha mode
  36069. */
  36070. getAlphaMode(): number;
  36071. /**
  36072. * Sets the current alpha equation
  36073. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36074. */
  36075. setAlphaEquation(equation: number): void;
  36076. /**
  36077. * Gets the current alpha equation.
  36078. * @returns the current alpha equation
  36079. */
  36080. getAlphaEquation(): number;
  36081. }
  36082. }
  36083. declare module BABYLON {
  36084. interface ThinEngine {
  36085. /** @hidden */
  36086. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36087. }
  36088. }
  36089. declare module BABYLON {
  36090. /**
  36091. * Defines the interface used by display changed events
  36092. */
  36093. export interface IDisplayChangedEventArgs {
  36094. /** Gets the vrDisplay object (if any) */
  36095. vrDisplay: Nullable<any>;
  36096. /** Gets a boolean indicating if webVR is supported */
  36097. vrSupported: boolean;
  36098. }
  36099. /**
  36100. * Defines the interface used by objects containing a viewport (like a camera)
  36101. */
  36102. interface IViewportOwnerLike {
  36103. /**
  36104. * Gets or sets the viewport
  36105. */
  36106. viewport: IViewportLike;
  36107. }
  36108. /**
  36109. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36110. */
  36111. export class Engine extends ThinEngine {
  36112. /** Defines that alpha blending is disabled */
  36113. static readonly ALPHA_DISABLE: number;
  36114. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36115. static readonly ALPHA_ADD: number;
  36116. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36117. static readonly ALPHA_COMBINE: number;
  36118. /** Defines that alpha blending to DEST - SRC * DEST */
  36119. static readonly ALPHA_SUBTRACT: number;
  36120. /** Defines that alpha blending to SRC * DEST */
  36121. static readonly ALPHA_MULTIPLY: number;
  36122. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36123. static readonly ALPHA_MAXIMIZED: number;
  36124. /** Defines that alpha blending to SRC + DEST */
  36125. static readonly ALPHA_ONEONE: number;
  36126. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36127. static readonly ALPHA_PREMULTIPLIED: number;
  36128. /**
  36129. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36130. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36131. */
  36132. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36133. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36134. static readonly ALPHA_INTERPOLATE: number;
  36135. /**
  36136. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36137. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36138. */
  36139. static readonly ALPHA_SCREENMODE: number;
  36140. /** Defines that the ressource is not delayed*/
  36141. static readonly DELAYLOADSTATE_NONE: number;
  36142. /** Defines that the ressource was successfully delay loaded */
  36143. static readonly DELAYLOADSTATE_LOADED: number;
  36144. /** Defines that the ressource is currently delay loading */
  36145. static readonly DELAYLOADSTATE_LOADING: number;
  36146. /** Defines that the ressource is delayed and has not started loading */
  36147. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36148. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36149. static readonly NEVER: number;
  36150. /** 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 */
  36151. static readonly ALWAYS: number;
  36152. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36153. static readonly LESS: number;
  36154. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36155. static readonly EQUAL: number;
  36156. /** 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 */
  36157. static readonly LEQUAL: number;
  36158. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36159. static readonly GREATER: number;
  36160. /** 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 */
  36161. static readonly GEQUAL: number;
  36162. /** 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 */
  36163. static readonly NOTEQUAL: number;
  36164. /** Passed to stencilOperation to specify that stencil value must be kept */
  36165. static readonly KEEP: number;
  36166. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36167. static readonly REPLACE: number;
  36168. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36169. static readonly INCR: number;
  36170. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36171. static readonly DECR: number;
  36172. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36173. static readonly INVERT: number;
  36174. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36175. static readonly INCR_WRAP: number;
  36176. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36177. static readonly DECR_WRAP: number;
  36178. /** Texture is not repeating outside of 0..1 UVs */
  36179. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36180. /** Texture is repeating outside of 0..1 UVs */
  36181. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36182. /** Texture is repeating and mirrored */
  36183. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36184. /** ALPHA */
  36185. static readonly TEXTUREFORMAT_ALPHA: number;
  36186. /** LUMINANCE */
  36187. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36188. /** LUMINANCE_ALPHA */
  36189. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36190. /** RGB */
  36191. static readonly TEXTUREFORMAT_RGB: number;
  36192. /** RGBA */
  36193. static readonly TEXTUREFORMAT_RGBA: number;
  36194. /** RED */
  36195. static readonly TEXTUREFORMAT_RED: number;
  36196. /** RED (2nd reference) */
  36197. static readonly TEXTUREFORMAT_R: number;
  36198. /** RG */
  36199. static readonly TEXTUREFORMAT_RG: number;
  36200. /** RED_INTEGER */
  36201. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36202. /** RED_INTEGER (2nd reference) */
  36203. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36204. /** RG_INTEGER */
  36205. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36206. /** RGB_INTEGER */
  36207. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36208. /** RGBA_INTEGER */
  36209. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36210. /** UNSIGNED_BYTE */
  36211. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36212. /** UNSIGNED_BYTE (2nd reference) */
  36213. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36214. /** FLOAT */
  36215. static readonly TEXTURETYPE_FLOAT: number;
  36216. /** HALF_FLOAT */
  36217. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36218. /** BYTE */
  36219. static readonly TEXTURETYPE_BYTE: number;
  36220. /** SHORT */
  36221. static readonly TEXTURETYPE_SHORT: number;
  36222. /** UNSIGNED_SHORT */
  36223. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36224. /** INT */
  36225. static readonly TEXTURETYPE_INT: number;
  36226. /** UNSIGNED_INT */
  36227. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36228. /** UNSIGNED_SHORT_4_4_4_4 */
  36229. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36230. /** UNSIGNED_SHORT_5_5_5_1 */
  36231. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36232. /** UNSIGNED_SHORT_5_6_5 */
  36233. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36234. /** UNSIGNED_INT_2_10_10_10_REV */
  36235. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36236. /** UNSIGNED_INT_24_8 */
  36237. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36238. /** UNSIGNED_INT_10F_11F_11F_REV */
  36239. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36240. /** UNSIGNED_INT_5_9_9_9_REV */
  36241. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36242. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36243. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36244. /** nearest is mag = nearest and min = nearest and mip = linear */
  36245. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36246. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36247. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36248. /** Trilinear is mag = linear and min = linear and mip = linear */
  36249. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36250. /** nearest is mag = nearest and min = nearest and mip = linear */
  36251. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36252. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36253. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36254. /** Trilinear is mag = linear and min = linear and mip = linear */
  36255. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36256. /** mag = nearest and min = nearest and mip = nearest */
  36257. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36258. /** mag = nearest and min = linear and mip = nearest */
  36259. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36260. /** mag = nearest and min = linear and mip = linear */
  36261. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36262. /** mag = nearest and min = linear and mip = none */
  36263. static readonly TEXTURE_NEAREST_LINEAR: number;
  36264. /** mag = nearest and min = nearest and mip = none */
  36265. static readonly TEXTURE_NEAREST_NEAREST: number;
  36266. /** mag = linear and min = nearest and mip = nearest */
  36267. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36268. /** mag = linear and min = nearest and mip = linear */
  36269. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36270. /** mag = linear and min = linear and mip = none */
  36271. static readonly TEXTURE_LINEAR_LINEAR: number;
  36272. /** mag = linear and min = nearest and mip = none */
  36273. static readonly TEXTURE_LINEAR_NEAREST: number;
  36274. /** Explicit coordinates mode */
  36275. static readonly TEXTURE_EXPLICIT_MODE: number;
  36276. /** Spherical coordinates mode */
  36277. static readonly TEXTURE_SPHERICAL_MODE: number;
  36278. /** Planar coordinates mode */
  36279. static readonly TEXTURE_PLANAR_MODE: number;
  36280. /** Cubic coordinates mode */
  36281. static readonly TEXTURE_CUBIC_MODE: number;
  36282. /** Projection coordinates mode */
  36283. static readonly TEXTURE_PROJECTION_MODE: number;
  36284. /** Skybox coordinates mode */
  36285. static readonly TEXTURE_SKYBOX_MODE: number;
  36286. /** Inverse Cubic coordinates mode */
  36287. static readonly TEXTURE_INVCUBIC_MODE: number;
  36288. /** Equirectangular coordinates mode */
  36289. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36290. /** Equirectangular Fixed coordinates mode */
  36291. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36292. /** Equirectangular Fixed Mirrored coordinates mode */
  36293. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36294. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36295. static readonly SCALEMODE_FLOOR: number;
  36296. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36297. static readonly SCALEMODE_NEAREST: number;
  36298. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36299. static readonly SCALEMODE_CEILING: number;
  36300. /**
  36301. * Returns the current npm package of the sdk
  36302. */
  36303. static get NpmPackage(): string;
  36304. /**
  36305. * Returns the current version of the framework
  36306. */
  36307. static get Version(): string;
  36308. /** Gets the list of created engines */
  36309. static get Instances(): Engine[];
  36310. /**
  36311. * Gets the latest created engine
  36312. */
  36313. static get LastCreatedEngine(): Nullable<Engine>;
  36314. /**
  36315. * Gets the latest created scene
  36316. */
  36317. static get LastCreatedScene(): Nullable<Scene>;
  36318. /**
  36319. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36320. * @param flag defines which part of the materials must be marked as dirty
  36321. * @param predicate defines a predicate used to filter which materials should be affected
  36322. */
  36323. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36324. /**
  36325. * Method called to create the default loading screen.
  36326. * This can be overriden in your own app.
  36327. * @param canvas The rendering canvas element
  36328. * @returns The loading screen
  36329. */
  36330. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36331. /**
  36332. * Method called to create the default rescale post process on each engine.
  36333. */
  36334. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36335. /**
  36336. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36337. **/
  36338. enableOfflineSupport: boolean;
  36339. /**
  36340. * 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)
  36341. **/
  36342. disableManifestCheck: boolean;
  36343. /**
  36344. * Gets the list of created scenes
  36345. */
  36346. scenes: Scene[];
  36347. /**
  36348. * Event raised when a new scene is created
  36349. */
  36350. onNewSceneAddedObservable: Observable<Scene>;
  36351. /**
  36352. * Gets the list of created postprocesses
  36353. */
  36354. postProcesses: PostProcess[];
  36355. /**
  36356. * Gets a boolean indicating if the pointer is currently locked
  36357. */
  36358. isPointerLock: boolean;
  36359. /**
  36360. * Observable event triggered each time the rendering canvas is resized
  36361. */
  36362. onResizeObservable: Observable<Engine>;
  36363. /**
  36364. * Observable event triggered each time the canvas loses focus
  36365. */
  36366. onCanvasBlurObservable: Observable<Engine>;
  36367. /**
  36368. * Observable event triggered each time the canvas gains focus
  36369. */
  36370. onCanvasFocusObservable: Observable<Engine>;
  36371. /**
  36372. * Observable event triggered each time the canvas receives pointerout event
  36373. */
  36374. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36375. /**
  36376. * Observable raised when the engine begins a new frame
  36377. */
  36378. onBeginFrameObservable: Observable<Engine>;
  36379. /**
  36380. * If set, will be used to request the next animation frame for the render loop
  36381. */
  36382. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36383. /**
  36384. * Observable raised when the engine ends the current frame
  36385. */
  36386. onEndFrameObservable: Observable<Engine>;
  36387. /**
  36388. * Observable raised when the engine is about to compile a shader
  36389. */
  36390. onBeforeShaderCompilationObservable: Observable<Engine>;
  36391. /**
  36392. * Observable raised when the engine has jsut compiled a shader
  36393. */
  36394. onAfterShaderCompilationObservable: Observable<Engine>;
  36395. /**
  36396. * Gets the audio engine
  36397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36398. * @ignorenaming
  36399. */
  36400. static audioEngine: IAudioEngine;
  36401. /**
  36402. * Default AudioEngine factory responsible of creating the Audio Engine.
  36403. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36404. */
  36405. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36406. /**
  36407. * Default offline support factory responsible of creating a tool used to store data locally.
  36408. * By default, this will create a Database object if the workload has been embedded.
  36409. */
  36410. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36411. private _loadingScreen;
  36412. private _pointerLockRequested;
  36413. private _rescalePostProcess;
  36414. private _deterministicLockstep;
  36415. private _lockstepMaxSteps;
  36416. private _timeStep;
  36417. protected get _supportsHardwareTextureRescaling(): boolean;
  36418. private _fps;
  36419. private _deltaTime;
  36420. /** @hidden */
  36421. _drawCalls: PerfCounter;
  36422. /** 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 */
  36423. canvasTabIndex: number;
  36424. /**
  36425. * Turn this value on if you want to pause FPS computation when in background
  36426. */
  36427. disablePerformanceMonitorInBackground: boolean;
  36428. private _performanceMonitor;
  36429. /**
  36430. * Gets the performance monitor attached to this engine
  36431. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36432. */
  36433. get performanceMonitor(): PerformanceMonitor;
  36434. private _onFocus;
  36435. private _onBlur;
  36436. private _onCanvasPointerOut;
  36437. private _onCanvasBlur;
  36438. private _onCanvasFocus;
  36439. private _onFullscreenChange;
  36440. private _onPointerLockChange;
  36441. /**
  36442. * Gets the HTML element used to attach event listeners
  36443. * @returns a HTML element
  36444. */
  36445. getInputElement(): Nullable<HTMLElement>;
  36446. /**
  36447. * Creates a new engine
  36448. * @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
  36449. * @param antialias defines enable antialiasing (default: false)
  36450. * @param options defines further options to be sent to the getContext() function
  36451. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36452. */
  36453. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36454. /**
  36455. * Gets current aspect ratio
  36456. * @param viewportOwner defines the camera to use to get the aspect ratio
  36457. * @param useScreen defines if screen size must be used (or the current render target if any)
  36458. * @returns a number defining the aspect ratio
  36459. */
  36460. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36461. /**
  36462. * Gets current screen aspect ratio
  36463. * @returns a number defining the aspect ratio
  36464. */
  36465. getScreenAspectRatio(): number;
  36466. /**
  36467. * Gets the client rect of the HTML canvas attached with the current webGL context
  36468. * @returns a client rectanglee
  36469. */
  36470. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36471. /**
  36472. * Gets the client rect of the HTML element used for events
  36473. * @returns a client rectanglee
  36474. */
  36475. getInputElementClientRect(): Nullable<ClientRect>;
  36476. /**
  36477. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36478. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36479. * @returns true if engine is in deterministic lock step mode
  36480. */
  36481. isDeterministicLockStep(): boolean;
  36482. /**
  36483. * Gets the max steps when engine is running in deterministic lock step
  36484. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36485. * @returns the max steps
  36486. */
  36487. getLockstepMaxSteps(): number;
  36488. /**
  36489. * Returns the time in ms between steps when using deterministic lock step.
  36490. * @returns time step in (ms)
  36491. */
  36492. getTimeStep(): number;
  36493. /**
  36494. * Force the mipmap generation for the given render target texture
  36495. * @param texture defines the render target texture to use
  36496. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36497. */
  36498. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36499. /** States */
  36500. /**
  36501. * Set various states to the webGL context
  36502. * @param culling defines backface culling state
  36503. * @param zOffset defines the value to apply to zOffset (0 by default)
  36504. * @param force defines if states must be applied even if cache is up to date
  36505. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36506. */
  36507. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36508. /**
  36509. * Set the z offset to apply to current rendering
  36510. * @param value defines the offset to apply
  36511. */
  36512. setZOffset(value: number): void;
  36513. /**
  36514. * Gets the current value of the zOffset
  36515. * @returns the current zOffset state
  36516. */
  36517. getZOffset(): number;
  36518. /**
  36519. * Enable or disable depth buffering
  36520. * @param enable defines the state to set
  36521. */
  36522. setDepthBuffer(enable: boolean): void;
  36523. /**
  36524. * Gets a boolean indicating if depth writing is enabled
  36525. * @returns the current depth writing state
  36526. */
  36527. getDepthWrite(): boolean;
  36528. /**
  36529. * Enable or disable depth writing
  36530. * @param enable defines the state to set
  36531. */
  36532. setDepthWrite(enable: boolean): void;
  36533. /**
  36534. * Gets a boolean indicating if stencil buffer is enabled
  36535. * @returns the current stencil buffer state
  36536. */
  36537. getStencilBuffer(): boolean;
  36538. /**
  36539. * Enable or disable the stencil buffer
  36540. * @param enable defines if the stencil buffer must be enabled or disabled
  36541. */
  36542. setStencilBuffer(enable: boolean): void;
  36543. /**
  36544. * Gets the current stencil mask
  36545. * @returns a number defining the new stencil mask to use
  36546. */
  36547. getStencilMask(): number;
  36548. /**
  36549. * Sets the current stencil mask
  36550. * @param mask defines the new stencil mask to use
  36551. */
  36552. setStencilMask(mask: number): void;
  36553. /**
  36554. * Gets the current stencil function
  36555. * @returns a number defining the stencil function to use
  36556. */
  36557. getStencilFunction(): number;
  36558. /**
  36559. * Gets the current stencil reference value
  36560. * @returns a number defining the stencil reference value to use
  36561. */
  36562. getStencilFunctionReference(): number;
  36563. /**
  36564. * Gets the current stencil mask
  36565. * @returns a number defining the stencil mask to use
  36566. */
  36567. getStencilFunctionMask(): number;
  36568. /**
  36569. * Sets the current stencil function
  36570. * @param stencilFunc defines the new stencil function to use
  36571. */
  36572. setStencilFunction(stencilFunc: number): void;
  36573. /**
  36574. * Sets the current stencil reference
  36575. * @param reference defines the new stencil reference to use
  36576. */
  36577. setStencilFunctionReference(reference: number): void;
  36578. /**
  36579. * Sets the current stencil mask
  36580. * @param mask defines the new stencil mask to use
  36581. */
  36582. setStencilFunctionMask(mask: number): void;
  36583. /**
  36584. * Gets the current stencil operation when stencil fails
  36585. * @returns a number defining stencil operation to use when stencil fails
  36586. */
  36587. getStencilOperationFail(): number;
  36588. /**
  36589. * Gets the current stencil operation when depth fails
  36590. * @returns a number defining stencil operation to use when depth fails
  36591. */
  36592. getStencilOperationDepthFail(): number;
  36593. /**
  36594. * Gets the current stencil operation when stencil passes
  36595. * @returns a number defining stencil operation to use when stencil passes
  36596. */
  36597. getStencilOperationPass(): number;
  36598. /**
  36599. * Sets the stencil operation to use when stencil fails
  36600. * @param operation defines the stencil operation to use when stencil fails
  36601. */
  36602. setStencilOperationFail(operation: number): void;
  36603. /**
  36604. * Sets the stencil operation to use when depth fails
  36605. * @param operation defines the stencil operation to use when depth fails
  36606. */
  36607. setStencilOperationDepthFail(operation: number): void;
  36608. /**
  36609. * Sets the stencil operation to use when stencil passes
  36610. * @param operation defines the stencil operation to use when stencil passes
  36611. */
  36612. setStencilOperationPass(operation: number): void;
  36613. /**
  36614. * Sets a boolean indicating if the dithering state is enabled or disabled
  36615. * @param value defines the dithering state
  36616. */
  36617. setDitheringState(value: boolean): void;
  36618. /**
  36619. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36620. * @param value defines the rasterizer state
  36621. */
  36622. setRasterizerState(value: boolean): void;
  36623. /**
  36624. * Gets the current depth function
  36625. * @returns a number defining the depth function
  36626. */
  36627. getDepthFunction(): Nullable<number>;
  36628. /**
  36629. * Sets the current depth function
  36630. * @param depthFunc defines the function to use
  36631. */
  36632. setDepthFunction(depthFunc: number): void;
  36633. /**
  36634. * Sets the current depth function to GREATER
  36635. */
  36636. setDepthFunctionToGreater(): void;
  36637. /**
  36638. * Sets the current depth function to GEQUAL
  36639. */
  36640. setDepthFunctionToGreaterOrEqual(): void;
  36641. /**
  36642. * Sets the current depth function to LESS
  36643. */
  36644. setDepthFunctionToLess(): void;
  36645. /**
  36646. * Sets the current depth function to LEQUAL
  36647. */
  36648. setDepthFunctionToLessOrEqual(): void;
  36649. private _cachedStencilBuffer;
  36650. private _cachedStencilFunction;
  36651. private _cachedStencilMask;
  36652. private _cachedStencilOperationPass;
  36653. private _cachedStencilOperationFail;
  36654. private _cachedStencilOperationDepthFail;
  36655. private _cachedStencilReference;
  36656. /**
  36657. * Caches the the state of the stencil buffer
  36658. */
  36659. cacheStencilState(): void;
  36660. /**
  36661. * Restores the state of the stencil buffer
  36662. */
  36663. restoreStencilState(): void;
  36664. /**
  36665. * Directly set the WebGL Viewport
  36666. * @param x defines the x coordinate of the viewport (in screen space)
  36667. * @param y defines the y coordinate of the viewport (in screen space)
  36668. * @param width defines the width of the viewport (in screen space)
  36669. * @param height defines the height of the viewport (in screen space)
  36670. * @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
  36671. */
  36672. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36673. /**
  36674. * Executes a scissor clear (ie. a clear 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. * @param clearColor defines the clear color
  36680. */
  36681. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36682. /**
  36683. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36684. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36685. * @param y defines the y-coordinate of the corner of the clear rectangle
  36686. * @param width defines the width of the clear rectangle
  36687. * @param height defines the height of the clear rectangle
  36688. */
  36689. enableScissor(x: number, y: number, width: number, height: number): void;
  36690. /**
  36691. * Disable previously set scissor test rectangle
  36692. */
  36693. disableScissor(): void;
  36694. protected _reportDrawCall(): void;
  36695. /**
  36696. * Initializes a webVR display and starts listening to display change events
  36697. * The onVRDisplayChangedObservable will be notified upon these changes
  36698. * @returns The onVRDisplayChangedObservable
  36699. */
  36700. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36701. /** @hidden */
  36702. _prepareVRComponent(): void;
  36703. /** @hidden */
  36704. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36705. /** @hidden */
  36706. _submitVRFrame(): void;
  36707. /**
  36708. * Call this function to leave webVR mode
  36709. * Will do nothing if webVR is not supported or if there is no webVR device
  36710. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36711. */
  36712. disableVR(): void;
  36713. /**
  36714. * Gets a boolean indicating that the system is in VR mode and is presenting
  36715. * @returns true if VR mode is engaged
  36716. */
  36717. isVRPresenting(): boolean;
  36718. /** @hidden */
  36719. _requestVRFrame(): void;
  36720. /** @hidden */
  36721. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36722. /**
  36723. * Gets the source code of the vertex shader associated with a specific webGL program
  36724. * @param program defines the program to use
  36725. * @returns a string containing the source code of the vertex shader associated with the program
  36726. */
  36727. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36728. /**
  36729. * Gets the source code of the fragment shader associated with a specific webGL program
  36730. * @param program defines the program to use
  36731. * @returns a string containing the source code of the fragment shader associated with the program
  36732. */
  36733. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36734. /**
  36735. * Sets a depth stencil texture from a render target to the according uniform.
  36736. * @param channel The texture channel
  36737. * @param uniform The uniform to set
  36738. * @param texture The render target texture containing the depth stencil texture to apply
  36739. */
  36740. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36741. /**
  36742. * Sets a texture to the webGL context from a postprocess
  36743. * @param channel defines the channel to use
  36744. * @param postProcess defines the source postprocess
  36745. */
  36746. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36747. /**
  36748. * Binds the output of the passed in post process to the texture channel specified
  36749. * @param channel The channel the texture should be bound to
  36750. * @param postProcess The post process which's output should be bound
  36751. */
  36752. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36753. protected _rebuildBuffers(): void;
  36754. /** @hidden */
  36755. _renderFrame(): void;
  36756. _renderLoop(): void;
  36757. /** @hidden */
  36758. _renderViews(): boolean;
  36759. /**
  36760. * Toggle full screen mode
  36761. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36762. */
  36763. switchFullscreen(requestPointerLock: boolean): void;
  36764. /**
  36765. * Enters full screen mode
  36766. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36767. */
  36768. enterFullscreen(requestPointerLock: boolean): void;
  36769. /**
  36770. * Exits full screen mode
  36771. */
  36772. exitFullscreen(): void;
  36773. /**
  36774. * Enters Pointerlock mode
  36775. */
  36776. enterPointerlock(): void;
  36777. /**
  36778. * Exits Pointerlock mode
  36779. */
  36780. exitPointerlock(): void;
  36781. /**
  36782. * Begin a new frame
  36783. */
  36784. beginFrame(): void;
  36785. /**
  36786. * Enf the current frame
  36787. */
  36788. endFrame(): void;
  36789. resize(): void;
  36790. /**
  36791. * Force a specific size of the canvas
  36792. * @param width defines the new canvas' width
  36793. * @param height defines the new canvas' height
  36794. */
  36795. setSize(width: number, height: number): void;
  36796. /**
  36797. * Updates a dynamic vertex buffer.
  36798. * @param vertexBuffer the vertex buffer to update
  36799. * @param data the data used to update the vertex buffer
  36800. * @param byteOffset the byte offset of the data
  36801. * @param byteLength the byte length of the data
  36802. */
  36803. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  36804. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36805. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36806. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36807. _releaseTexture(texture: InternalTexture): void;
  36808. /**
  36809. * @hidden
  36810. * Rescales a texture
  36811. * @param source input texutre
  36812. * @param destination destination texture
  36813. * @param scene scene to use to render the resize
  36814. * @param internalFormat format to use when resizing
  36815. * @param onComplete callback to be called when resize has completed
  36816. */
  36817. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36818. /**
  36819. * Gets the current framerate
  36820. * @returns a number representing the framerate
  36821. */
  36822. getFps(): number;
  36823. /**
  36824. * Gets the time spent between current and previous frame
  36825. * @returns a number representing the delta time in ms
  36826. */
  36827. getDeltaTime(): number;
  36828. private _measureFps;
  36829. /** @hidden */
  36830. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  36831. /**
  36832. * Update a dynamic index buffer
  36833. * @param indexBuffer defines the target index buffer
  36834. * @param indices defines the data to update
  36835. * @param offset defines the offset in the target index buffer where update should start
  36836. */
  36837. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  36838. /**
  36839. * Updates the sample count of a render target texture
  36840. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  36841. * @param texture defines the texture to update
  36842. * @param samples defines the sample count to set
  36843. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  36844. */
  36845. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  36846. /**
  36847. * Updates a depth texture Comparison Mode and Function.
  36848. * If the comparison Function is equal to 0, the mode will be set to none.
  36849. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  36850. * @param texture The texture to set the comparison function for
  36851. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  36852. */
  36853. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  36854. /**
  36855. * Creates a webGL buffer to use with instanciation
  36856. * @param capacity defines the size of the buffer
  36857. * @returns the webGL buffer
  36858. */
  36859. createInstancesBuffer(capacity: number): DataBuffer;
  36860. /**
  36861. * Delete a webGL buffer used with instanciation
  36862. * @param buffer defines the webGL buffer to delete
  36863. */
  36864. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  36865. private _clientWaitAsync;
  36866. /** @hidden */
  36867. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  36868. dispose(): void;
  36869. private _disableTouchAction;
  36870. /**
  36871. * Display the loading screen
  36872. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36873. */
  36874. displayLoadingUI(): void;
  36875. /**
  36876. * Hide the loading screen
  36877. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36878. */
  36879. hideLoadingUI(): void;
  36880. /**
  36881. * Gets the current loading screen object
  36882. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36883. */
  36884. get loadingScreen(): ILoadingScreen;
  36885. /**
  36886. * Sets the current loading screen object
  36887. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36888. */
  36889. set loadingScreen(loadingScreen: ILoadingScreen);
  36890. /**
  36891. * Sets the current loading screen text
  36892. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36893. */
  36894. set loadingUIText(text: string);
  36895. /**
  36896. * Sets the current loading screen background color
  36897. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36898. */
  36899. set loadingUIBackgroundColor(color: string);
  36900. /** Pointerlock and fullscreen */
  36901. /**
  36902. * Ask the browser to promote the current element to pointerlock mode
  36903. * @param element defines the DOM element to promote
  36904. */
  36905. static _RequestPointerlock(element: HTMLElement): void;
  36906. /**
  36907. * Asks the browser to exit pointerlock mode
  36908. */
  36909. static _ExitPointerlock(): void;
  36910. /**
  36911. * Ask the browser to promote the current element to fullscreen rendering mode
  36912. * @param element defines the DOM element to promote
  36913. */
  36914. static _RequestFullscreen(element: HTMLElement): void;
  36915. /**
  36916. * Asks the browser to exit fullscreen mode
  36917. */
  36918. static _ExitFullscreen(): void;
  36919. }
  36920. }
  36921. declare module BABYLON {
  36922. /**
  36923. * The engine store class is responsible to hold all the instances of Engine and Scene created
  36924. * during the life time of the application.
  36925. */
  36926. export class EngineStore {
  36927. /** Gets the list of created engines */
  36928. static Instances: Engine[];
  36929. /** @hidden */
  36930. static _LastCreatedScene: Nullable<Scene>;
  36931. /**
  36932. * Gets the latest created engine
  36933. */
  36934. static get LastCreatedEngine(): Nullable<Engine>;
  36935. /**
  36936. * Gets the latest created scene
  36937. */
  36938. static get LastCreatedScene(): Nullable<Scene>;
  36939. /**
  36940. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  36941. * @ignorenaming
  36942. */
  36943. static UseFallbackTexture: boolean;
  36944. /**
  36945. * Texture content used if a texture cannot loaded
  36946. * @ignorenaming
  36947. */
  36948. static FallbackTexture: string;
  36949. }
  36950. }
  36951. declare module BABYLON {
  36952. /**
  36953. * Helper class that provides a small promise polyfill
  36954. */
  36955. export class PromisePolyfill {
  36956. /**
  36957. * Static function used to check if the polyfill is required
  36958. * If this is the case then the function will inject the polyfill to window.Promise
  36959. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  36960. */
  36961. static Apply(force?: boolean): void;
  36962. }
  36963. }
  36964. declare module BABYLON {
  36965. /**
  36966. * Interface for screenshot methods with describe argument called `size` as object with options
  36967. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  36968. */
  36969. export interface IScreenshotSize {
  36970. /**
  36971. * number in pixels for canvas height
  36972. */
  36973. height?: number;
  36974. /**
  36975. * multiplier allowing render at a higher or lower resolution
  36976. * If value is defined then height and width will be ignored and taken from camera
  36977. */
  36978. precision?: number;
  36979. /**
  36980. * number in pixels for canvas width
  36981. */
  36982. width?: number;
  36983. }
  36984. }
  36985. declare module BABYLON {
  36986. interface IColor4Like {
  36987. r: float;
  36988. g: float;
  36989. b: float;
  36990. a: float;
  36991. }
  36992. /**
  36993. * Class containing a set of static utilities functions
  36994. */
  36995. export class Tools {
  36996. /**
  36997. * Gets or sets the base URL to use to load assets
  36998. */
  36999. static get BaseUrl(): string;
  37000. static set BaseUrl(value: string);
  37001. /**
  37002. * Enable/Disable Custom HTTP Request Headers globally.
  37003. * default = false
  37004. * @see CustomRequestHeaders
  37005. */
  37006. static UseCustomRequestHeaders: boolean;
  37007. /**
  37008. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37009. * i.e. when loading files, where the server/service expects an Authorization header
  37010. */
  37011. static CustomRequestHeaders: {
  37012. [key: string]: string;
  37013. };
  37014. /**
  37015. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37016. */
  37017. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37018. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37019. /**
  37020. * Default behaviour for cors in the application.
  37021. * It can be a string if the expected behavior is identical in the entire app.
  37022. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37023. */
  37024. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37025. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37026. /**
  37027. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37028. * @ignorenaming
  37029. */
  37030. static get UseFallbackTexture(): boolean;
  37031. static set UseFallbackTexture(value: boolean);
  37032. /**
  37033. * Use this object to register external classes like custom textures or material
  37034. * to allow the laoders to instantiate them
  37035. */
  37036. static get RegisteredExternalClasses(): {
  37037. [key: string]: Object;
  37038. };
  37039. static set RegisteredExternalClasses(classes: {
  37040. [key: string]: Object;
  37041. });
  37042. /**
  37043. * Texture content used if a texture cannot loaded
  37044. * @ignorenaming
  37045. */
  37046. static get fallbackTexture(): string;
  37047. static set fallbackTexture(value: string);
  37048. /**
  37049. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37050. * @param u defines the coordinate on X axis
  37051. * @param v defines the coordinate on Y axis
  37052. * @param width defines the width of the source data
  37053. * @param height defines the height of the source data
  37054. * @param pixels defines the source byte array
  37055. * @param color defines the output color
  37056. */
  37057. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37058. /**
  37059. * Interpolates between a and b via alpha
  37060. * @param a The lower value (returned when alpha = 0)
  37061. * @param b The upper value (returned when alpha = 1)
  37062. * @param alpha The interpolation-factor
  37063. * @return The mixed value
  37064. */
  37065. static Mix(a: number, b: number, alpha: number): number;
  37066. /**
  37067. * Tries to instantiate a new object from a given class name
  37068. * @param className defines the class name to instantiate
  37069. * @returns the new object or null if the system was not able to do the instantiation
  37070. */
  37071. static Instantiate(className: string): any;
  37072. /**
  37073. * Provides a slice function that will work even on IE
  37074. * @param data defines the array to slice
  37075. * @param start defines the start of the data (optional)
  37076. * @param end defines the end of the data (optional)
  37077. * @returns the new sliced array
  37078. */
  37079. static Slice<T>(data: T, start?: number, end?: number): T;
  37080. /**
  37081. * Polyfill for setImmediate
  37082. * @param action defines the action to execute after the current execution block
  37083. */
  37084. static SetImmediate(action: () => void): void;
  37085. /**
  37086. * Function indicating if a number is an exponent of 2
  37087. * @param value defines the value to test
  37088. * @returns true if the value is an exponent of 2
  37089. */
  37090. static IsExponentOfTwo(value: number): boolean;
  37091. private static _tmpFloatArray;
  37092. /**
  37093. * Returns the nearest 32-bit single precision float representation of a Number
  37094. * @param value A Number. If the parameter is of a different type, it will get converted
  37095. * to a number or to NaN if it cannot be converted
  37096. * @returns number
  37097. */
  37098. static FloatRound(value: number): number;
  37099. /**
  37100. * Extracts the filename from a path
  37101. * @param path defines the path to use
  37102. * @returns the filename
  37103. */
  37104. static GetFilename(path: string): string;
  37105. /**
  37106. * Extracts the "folder" part of a path (everything before the filename).
  37107. * @param uri The URI to extract the info from
  37108. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37109. * @returns The "folder" part of the path
  37110. */
  37111. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37112. /**
  37113. * Extracts text content from a DOM element hierarchy
  37114. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37115. */
  37116. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37117. /**
  37118. * Convert an angle in radians to degrees
  37119. * @param angle defines the angle to convert
  37120. * @returns the angle in degrees
  37121. */
  37122. static ToDegrees(angle: number): number;
  37123. /**
  37124. * Convert an angle in degrees to radians
  37125. * @param angle defines the angle to convert
  37126. * @returns the angle in radians
  37127. */
  37128. static ToRadians(angle: number): number;
  37129. /**
  37130. * Returns an array if obj is not an array
  37131. * @param obj defines the object to evaluate as an array
  37132. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37133. * @returns either obj directly if obj is an array or a new array containing obj
  37134. */
  37135. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37136. /**
  37137. * Gets the pointer prefix to use
  37138. * @param engine defines the engine we are finding the prefix for
  37139. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37140. */
  37141. static GetPointerPrefix(engine: Engine): string;
  37142. /**
  37143. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37144. * @param url define the url we are trying
  37145. * @param element define the dom element where to configure the cors policy
  37146. */
  37147. static SetCorsBehavior(url: string | string[], element: {
  37148. crossOrigin: string | null;
  37149. }): void;
  37150. /**
  37151. * Removes unwanted characters from an url
  37152. * @param url defines the url to clean
  37153. * @returns the cleaned url
  37154. */
  37155. static CleanUrl(url: string): string;
  37156. /**
  37157. * Gets or sets a function used to pre-process url before using them to load assets
  37158. */
  37159. static get PreprocessUrl(): (url: string) => string;
  37160. static set PreprocessUrl(processor: (url: string) => string);
  37161. /**
  37162. * Loads an image as an HTMLImageElement.
  37163. * @param input url string, ArrayBuffer, or Blob to load
  37164. * @param onLoad callback called when the image successfully loads
  37165. * @param onError callback called when the image fails to load
  37166. * @param offlineProvider offline provider for caching
  37167. * @param mimeType optional mime type
  37168. * @returns the HTMLImageElement of the loaded image
  37169. */
  37170. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37171. /**
  37172. * Loads a file from a url
  37173. * @param url url string, ArrayBuffer, or Blob to load
  37174. * @param onSuccess callback called when the file successfully loads
  37175. * @param onProgress callback called while file is loading (if the server supports this mode)
  37176. * @param offlineProvider defines the offline provider for caching
  37177. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37178. * @param onError callback called when the file fails to load
  37179. * @returns a file request object
  37180. */
  37181. 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;
  37182. /**
  37183. * Loads a file from a url
  37184. * @param url the file url to load
  37185. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37186. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37187. */
  37188. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37189. /**
  37190. * Load a 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 onSuccess defines the callback called when the script is loaded
  37194. * @param onError defines the callback to call if an error occurs
  37195. * @param scriptId defines the id of the script element
  37196. */
  37197. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37198. /**
  37199. * Load an asynchronous script (identified by an url). When the url returns, the
  37200. * content of this file is added into a new script element, attached to the DOM (body element)
  37201. * @param scriptUrl defines the url of the script to laod
  37202. * @param scriptId defines the id of the script element
  37203. * @returns a promise request object
  37204. */
  37205. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37206. /**
  37207. * Loads a file from a blob
  37208. * @param fileToLoad defines the blob to use
  37209. * @param callback defines the callback to call when data is loaded
  37210. * @param progressCallback defines the callback to call during loading process
  37211. * @returns a file request object
  37212. */
  37213. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37214. /**
  37215. * Reads a file from a File object
  37216. * @param file defines the file to load
  37217. * @param onSuccess defines the callback to call when data is loaded
  37218. * @param onProgress defines the callback to call during loading process
  37219. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37220. * @param onError defines the callback to call when an error occurs
  37221. * @returns a file request object
  37222. */
  37223. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37224. /**
  37225. * Creates a data url from a given string content
  37226. * @param content defines the content to convert
  37227. * @returns the new data url link
  37228. */
  37229. static FileAsURL(content: string): string;
  37230. /**
  37231. * Format the given number to a specific decimal format
  37232. * @param value defines the number to format
  37233. * @param decimals defines the number of decimals to use
  37234. * @returns the formatted string
  37235. */
  37236. static Format(value: number, decimals?: number): string;
  37237. /**
  37238. * Tries to copy an object by duplicating every property
  37239. * @param source defines the source object
  37240. * @param destination defines the target object
  37241. * @param doNotCopyList defines a list of properties to avoid
  37242. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37243. */
  37244. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37245. /**
  37246. * Gets a boolean indicating if the given object has no own property
  37247. * @param obj defines the object to test
  37248. * @returns true if object has no own property
  37249. */
  37250. static IsEmpty(obj: any): boolean;
  37251. /**
  37252. * Function used to register events at window level
  37253. * @param windowElement defines the Window object to use
  37254. * @param events defines the events to register
  37255. */
  37256. static RegisterTopRootEvents(windowElement: Window, events: {
  37257. name: string;
  37258. handler: Nullable<(e: FocusEvent) => any>;
  37259. }[]): void;
  37260. /**
  37261. * Function used to unregister events from window level
  37262. * @param windowElement defines the Window object to use
  37263. * @param events defines the events to unregister
  37264. */
  37265. static UnregisterTopRootEvents(windowElement: Window, events: {
  37266. name: string;
  37267. handler: Nullable<(e: FocusEvent) => any>;
  37268. }[]): void;
  37269. /**
  37270. * @ignore
  37271. */
  37272. static _ScreenshotCanvas: HTMLCanvasElement;
  37273. /**
  37274. * Dumps the current bound framebuffer
  37275. * @param width defines the rendering width
  37276. * @param height defines the rendering height
  37277. * @param engine defines the hosting engine
  37278. * @param successCallback defines the callback triggered once the data are available
  37279. * @param mimeType defines the mime type of the result
  37280. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37281. */
  37282. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37283. /**
  37284. * Converts the canvas data to blob.
  37285. * This acts as a polyfill for browsers not supporting the to blob function.
  37286. * @param canvas Defines the canvas to extract the data from
  37287. * @param successCallback Defines the callback triggered once the data are available
  37288. * @param mimeType Defines the mime type of the result
  37289. */
  37290. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37291. /**
  37292. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37293. * @param successCallback defines the callback triggered once the data are available
  37294. * @param mimeType defines the mime type of the result
  37295. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37296. */
  37297. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37298. /**
  37299. * Downloads a blob in the browser
  37300. * @param blob defines the blob to download
  37301. * @param fileName defines the name of the downloaded file
  37302. */
  37303. static Download(blob: Blob, fileName: string): void;
  37304. /**
  37305. * Captures a screenshot of the current rendering
  37306. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37307. * @param engine defines the rendering engine
  37308. * @param camera defines the source camera
  37309. * @param size This parameter can be set to a single number or to an object with the
  37310. * following (optional) properties: precision, width, height. If a single number is passed,
  37311. * it will be used for both width and height. If an object is passed, the screenshot size
  37312. * will be derived from the parameters. The precision property is a multiplier allowing
  37313. * rendering at a higher or lower resolution
  37314. * @param successCallback defines the callback receives a single parameter which contains the
  37315. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37316. * src parameter of an <img> to display it
  37317. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37318. * Check your browser for supported MIME types
  37319. */
  37320. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37321. /**
  37322. * Captures a screenshot of the current rendering
  37323. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37324. * @param engine defines the rendering engine
  37325. * @param camera defines the source camera
  37326. * @param size This parameter can be set to a single number or to an object with the
  37327. * following (optional) properties: precision, width, height. If a single number is passed,
  37328. * it will be used for both width and height. If an object is passed, the screenshot size
  37329. * will be derived from the parameters. The precision property is a multiplier allowing
  37330. * rendering at a higher or lower resolution
  37331. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37332. * Check your browser for supported MIME types
  37333. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37334. * to the src parameter of an <img> to display it
  37335. */
  37336. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37337. /**
  37338. * Generates an image screenshot from the specified camera.
  37339. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37340. * @param engine The engine to use for rendering
  37341. * @param camera The camera to use for rendering
  37342. * @param size This parameter can be set to a single number or to an object with the
  37343. * following (optional) properties: precision, width, height. If a single number is passed,
  37344. * it will be used for both width and height. If an object is passed, the screenshot size
  37345. * will be derived from the parameters. The precision property is a multiplier allowing
  37346. * rendering at a higher or lower resolution
  37347. * @param successCallback The callback receives a single parameter which contains the
  37348. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37349. * src parameter of an <img> to display it
  37350. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37351. * Check your browser for supported MIME types
  37352. * @param samples Texture samples (default: 1)
  37353. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37354. * @param fileName A name for for the downloaded file.
  37355. */
  37356. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37357. /**
  37358. * Generates an image screenshot from the specified camera.
  37359. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37360. * @param engine The engine to use for rendering
  37361. * @param camera The camera to use for rendering
  37362. * @param size This parameter can be set to a single number or to an object with the
  37363. * following (optional) properties: precision, width, height. If a single number is passed,
  37364. * it will be used for both width and height. If an object is passed, the screenshot size
  37365. * will be derived from the parameters. The precision property is a multiplier allowing
  37366. * rendering at a higher or lower resolution
  37367. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37368. * Check your browser for supported MIME types
  37369. * @param samples Texture samples (default: 1)
  37370. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37371. * @param fileName A name for for the downloaded file.
  37372. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37373. * to the src parameter of an <img> to display it
  37374. */
  37375. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37376. /**
  37377. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37378. * Be aware Math.random() could cause collisions, but:
  37379. * "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"
  37380. * @returns a pseudo random id
  37381. */
  37382. static RandomId(): string;
  37383. /**
  37384. * Test if the given uri is a base64 string
  37385. * @param uri The uri to test
  37386. * @return True if the uri is a base64 string or false otherwise
  37387. */
  37388. static IsBase64(uri: string): boolean;
  37389. /**
  37390. * Decode the given base64 uri.
  37391. * @param uri The uri to decode
  37392. * @return The decoded base64 data.
  37393. */
  37394. static DecodeBase64(uri: string): ArrayBuffer;
  37395. /**
  37396. * Gets the absolute url.
  37397. * @param url the input url
  37398. * @return the absolute url
  37399. */
  37400. static GetAbsoluteUrl(url: string): string;
  37401. /**
  37402. * No log
  37403. */
  37404. static readonly NoneLogLevel: number;
  37405. /**
  37406. * Only message logs
  37407. */
  37408. static readonly MessageLogLevel: number;
  37409. /**
  37410. * Only warning logs
  37411. */
  37412. static readonly WarningLogLevel: number;
  37413. /**
  37414. * Only error logs
  37415. */
  37416. static readonly ErrorLogLevel: number;
  37417. /**
  37418. * All logs
  37419. */
  37420. static readonly AllLogLevel: number;
  37421. /**
  37422. * Gets a value indicating the number of loading errors
  37423. * @ignorenaming
  37424. */
  37425. static get errorsCount(): number;
  37426. /**
  37427. * Callback called when a new log is added
  37428. */
  37429. static OnNewCacheEntry: (entry: string) => void;
  37430. /**
  37431. * Log a message to the console
  37432. * @param message defines the message to log
  37433. */
  37434. static Log(message: string): void;
  37435. /**
  37436. * Write a warning message to the console
  37437. * @param message defines the message to log
  37438. */
  37439. static Warn(message: string): void;
  37440. /**
  37441. * Write an error message to the console
  37442. * @param message defines the message to log
  37443. */
  37444. static Error(message: string): void;
  37445. /**
  37446. * Gets current log cache (list of logs)
  37447. */
  37448. static get LogCache(): string;
  37449. /**
  37450. * Clears the log cache
  37451. */
  37452. static ClearLogCache(): void;
  37453. /**
  37454. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37455. */
  37456. static set LogLevels(level: number);
  37457. /**
  37458. * Checks if the window object exists
  37459. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37460. */
  37461. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37462. /**
  37463. * No performance log
  37464. */
  37465. static readonly PerformanceNoneLogLevel: number;
  37466. /**
  37467. * Use user marks to log performance
  37468. */
  37469. static readonly PerformanceUserMarkLogLevel: number;
  37470. /**
  37471. * Log performance to the console
  37472. */
  37473. static readonly PerformanceConsoleLogLevel: number;
  37474. private static _performance;
  37475. /**
  37476. * Sets the current performance log level
  37477. */
  37478. static set PerformanceLogLevel(level: number);
  37479. private static _StartPerformanceCounterDisabled;
  37480. private static _EndPerformanceCounterDisabled;
  37481. private static _StartUserMark;
  37482. private static _EndUserMark;
  37483. private static _StartPerformanceConsole;
  37484. private static _EndPerformanceConsole;
  37485. /**
  37486. * Starts a performance counter
  37487. */
  37488. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37489. /**
  37490. * Ends a specific performance coutner
  37491. */
  37492. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37493. /**
  37494. * Gets either window.performance.now() if supported or Date.now() else
  37495. */
  37496. static get Now(): number;
  37497. /**
  37498. * This method will return the name of the class used to create the instance of the given object.
  37499. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37500. * @param object the object to get the class name from
  37501. * @param isType defines if the object is actually a type
  37502. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37503. */
  37504. static GetClassName(object: any, isType?: boolean): string;
  37505. /**
  37506. * Gets the first element of an array satisfying a given predicate
  37507. * @param array defines the array to browse
  37508. * @param predicate defines the predicate to use
  37509. * @returns null if not found or the element
  37510. */
  37511. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37512. /**
  37513. * This method will return the name of the full name of the class, including its owning module (if any).
  37514. * 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).
  37515. * @param object the object to get the class name from
  37516. * @param isType defines if the object is actually a type
  37517. * @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.
  37518. * @ignorenaming
  37519. */
  37520. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37521. /**
  37522. * Returns a promise that resolves after the given amount of time.
  37523. * @param delay Number of milliseconds to delay
  37524. * @returns Promise that resolves after the given amount of time
  37525. */
  37526. static DelayAsync(delay: number): Promise<void>;
  37527. /**
  37528. * Utility function to detect if the current user agent is Safari
  37529. * @returns whether or not the current user agent is safari
  37530. */
  37531. static IsSafari(): boolean;
  37532. }
  37533. /**
  37534. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37535. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37536. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37537. * @param name The name of the class, case should be preserved
  37538. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37539. */
  37540. export function className(name: string, module?: string): (target: Object) => void;
  37541. /**
  37542. * An implementation of a loop for asynchronous functions.
  37543. */
  37544. export class AsyncLoop {
  37545. /**
  37546. * Defines the number of iterations for the loop
  37547. */
  37548. iterations: number;
  37549. /**
  37550. * Defines the current index of the loop.
  37551. */
  37552. index: number;
  37553. private _done;
  37554. private _fn;
  37555. private _successCallback;
  37556. /**
  37557. * Constructor.
  37558. * @param iterations the number of iterations.
  37559. * @param func the function to run each iteration
  37560. * @param successCallback the callback that will be called upon succesful execution
  37561. * @param offset starting offset.
  37562. */
  37563. constructor(
  37564. /**
  37565. * Defines the number of iterations for the loop
  37566. */
  37567. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37568. /**
  37569. * Execute the next iteration. Must be called after the last iteration was finished.
  37570. */
  37571. executeNext(): void;
  37572. /**
  37573. * Break the loop and run the success callback.
  37574. */
  37575. breakLoop(): void;
  37576. /**
  37577. * Create and run an async loop.
  37578. * @param iterations the number of iterations.
  37579. * @param fn the function to run each iteration
  37580. * @param successCallback the callback that will be called upon succesful execution
  37581. * @param offset starting offset.
  37582. * @returns the created async loop object
  37583. */
  37584. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37585. /**
  37586. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37587. * @param iterations total number of iterations
  37588. * @param syncedIterations number of synchronous iterations in each async iteration.
  37589. * @param fn the function to call each iteration.
  37590. * @param callback a success call back that will be called when iterating stops.
  37591. * @param breakFunction a break condition (optional)
  37592. * @param timeout timeout settings for the setTimeout function. default - 0.
  37593. * @returns the created async loop object
  37594. */
  37595. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37596. }
  37597. }
  37598. declare module BABYLON {
  37599. /**
  37600. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37601. * The underlying implementation relies on an associative array to ensure the best performances.
  37602. * The value can be anything including 'null' but except 'undefined'
  37603. */
  37604. export class StringDictionary<T> {
  37605. /**
  37606. * This will clear this dictionary and copy the content from the 'source' one.
  37607. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37608. * @param source the dictionary to take the content from and copy to this dictionary
  37609. */
  37610. copyFrom(source: StringDictionary<T>): void;
  37611. /**
  37612. * Get a value based from its key
  37613. * @param key the given key to get the matching value from
  37614. * @return the value if found, otherwise undefined is returned
  37615. */
  37616. get(key: string): T | undefined;
  37617. /**
  37618. * Get a value from its key or add it if it doesn't exist.
  37619. * This method will ensure you that a given key/data will be present in the dictionary.
  37620. * @param key the given key to get the matching value from
  37621. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37622. * The factory will only be invoked if there's no data for the given key.
  37623. * @return the value corresponding to the key.
  37624. */
  37625. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37626. /**
  37627. * Get a value from its key if present in the dictionary otherwise add it
  37628. * @param key the key to get the value from
  37629. * @param val if there's no such key/value pair in the dictionary add it with this value
  37630. * @return the value corresponding to the key
  37631. */
  37632. getOrAdd(key: string, val: T): T;
  37633. /**
  37634. * Check if there's a given key in the dictionary
  37635. * @param key the key to check for
  37636. * @return true if the key is present, false otherwise
  37637. */
  37638. contains(key: string): boolean;
  37639. /**
  37640. * Add a new key and its corresponding value
  37641. * @param key the key to add
  37642. * @param value the value corresponding to the key
  37643. * @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
  37644. */
  37645. add(key: string, value: T): boolean;
  37646. /**
  37647. * Update a specific value associated to a key
  37648. * @param key defines the key to use
  37649. * @param value defines the value to store
  37650. * @returns true if the value was updated (or false if the key was not found)
  37651. */
  37652. set(key: string, value: T): boolean;
  37653. /**
  37654. * Get the element of the given key and remove it from the dictionary
  37655. * @param key defines the key to search
  37656. * @returns the value associated with the key or null if not found
  37657. */
  37658. getAndRemove(key: string): Nullable<T>;
  37659. /**
  37660. * Remove a key/value from the dictionary.
  37661. * @param key the key to remove
  37662. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37663. */
  37664. remove(key: string): boolean;
  37665. /**
  37666. * Clear the whole content of the dictionary
  37667. */
  37668. clear(): void;
  37669. /**
  37670. * Gets the current count
  37671. */
  37672. get count(): number;
  37673. /**
  37674. * Execute a callback on each key/val of the dictionary.
  37675. * Note that you can remove any element in this dictionary in the callback implementation
  37676. * @param callback the callback to execute on a given key/value pair
  37677. */
  37678. forEach(callback: (key: string, val: T) => void): void;
  37679. /**
  37680. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37681. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37682. * Note that you can remove any element in this dictionary in the callback implementation
  37683. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37684. * @returns the first item
  37685. */
  37686. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37687. private _count;
  37688. private _data;
  37689. }
  37690. }
  37691. declare module BABYLON {
  37692. /** @hidden */
  37693. export interface ICollisionCoordinator {
  37694. createCollider(): Collider;
  37695. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37696. init(scene: Scene): void;
  37697. }
  37698. /** @hidden */
  37699. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37700. private _scene;
  37701. private _scaledPosition;
  37702. private _scaledVelocity;
  37703. private _finalPosition;
  37704. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37705. createCollider(): Collider;
  37706. init(scene: Scene): void;
  37707. private _collideWithWorld;
  37708. }
  37709. }
  37710. declare module BABYLON {
  37711. /**
  37712. * Class used to manage all inputs for the scene.
  37713. */
  37714. export class InputManager {
  37715. /** The distance in pixel that you have to move to prevent some events */
  37716. static DragMovementThreshold: number;
  37717. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37718. static LongPressDelay: number;
  37719. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37720. static DoubleClickDelay: number;
  37721. /** If you need to check double click without raising a single click at first click, enable this flag */
  37722. static ExclusiveDoubleClickMode: boolean;
  37723. private _wheelEventName;
  37724. private _onPointerMove;
  37725. private _onPointerDown;
  37726. private _onPointerUp;
  37727. private _initClickEvent;
  37728. private _initActionManager;
  37729. private _delayedSimpleClick;
  37730. private _delayedSimpleClickTimeout;
  37731. private _previousDelayedSimpleClickTimeout;
  37732. private _meshPickProceed;
  37733. private _previousButtonPressed;
  37734. private _currentPickResult;
  37735. private _previousPickResult;
  37736. private _totalPointersPressed;
  37737. private _doubleClickOccured;
  37738. private _pointerOverMesh;
  37739. private _pickedDownMesh;
  37740. private _pickedUpMesh;
  37741. private _pointerX;
  37742. private _pointerY;
  37743. private _unTranslatedPointerX;
  37744. private _unTranslatedPointerY;
  37745. private _startingPointerPosition;
  37746. private _previousStartingPointerPosition;
  37747. private _startingPointerTime;
  37748. private _previousStartingPointerTime;
  37749. private _pointerCaptures;
  37750. private _onKeyDown;
  37751. private _onKeyUp;
  37752. private _onCanvasFocusObserver;
  37753. private _onCanvasBlurObserver;
  37754. private _scene;
  37755. /**
  37756. * Creates a new InputManager
  37757. * @param scene defines the hosting scene
  37758. */
  37759. constructor(scene: Scene);
  37760. /**
  37761. * Gets the mesh that is currently under the pointer
  37762. */
  37763. get meshUnderPointer(): Nullable<AbstractMesh>;
  37764. /**
  37765. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37766. */
  37767. get unTranslatedPointer(): Vector2;
  37768. /**
  37769. * Gets or sets the current on-screen X position of the pointer
  37770. */
  37771. get pointerX(): number;
  37772. set pointerX(value: number);
  37773. /**
  37774. * Gets or sets the current on-screen Y position of the pointer
  37775. */
  37776. get pointerY(): number;
  37777. set pointerY(value: number);
  37778. private _updatePointerPosition;
  37779. private _processPointerMove;
  37780. private _setRayOnPointerInfo;
  37781. private _checkPrePointerObservable;
  37782. /**
  37783. * Use this method to simulate a pointer move on a mesh
  37784. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37785. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37786. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37787. */
  37788. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37789. /**
  37790. * Use this method to simulate a pointer down on a mesh
  37791. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37792. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37793. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37794. */
  37795. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37796. private _processPointerDown;
  37797. /** @hidden */
  37798. _isPointerSwiping(): boolean;
  37799. /**
  37800. * Use this method to simulate a pointer up on a mesh
  37801. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37802. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37803. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37804. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37805. */
  37806. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  37807. private _processPointerUp;
  37808. /**
  37809. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37810. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37811. * @returns true if the pointer was captured
  37812. */
  37813. isPointerCaptured(pointerId?: number): boolean;
  37814. /**
  37815. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37816. * @param attachUp defines if you want to attach events to pointerup
  37817. * @param attachDown defines if you want to attach events to pointerdown
  37818. * @param attachMove defines if you want to attach events to pointermove
  37819. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  37820. */
  37821. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  37822. /**
  37823. * Detaches all event handlers
  37824. */
  37825. detachControl(): void;
  37826. /**
  37827. * Force the value of meshUnderPointer
  37828. * @param mesh defines the mesh to use
  37829. */
  37830. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37831. /**
  37832. * Gets the mesh under the pointer
  37833. * @returns a Mesh or null if no mesh is under the pointer
  37834. */
  37835. getPointerOverMesh(): Nullable<AbstractMesh>;
  37836. }
  37837. }
  37838. declare module BABYLON {
  37839. /**
  37840. * This class defines the direct association between an animation and a target
  37841. */
  37842. export class TargetedAnimation {
  37843. /**
  37844. * Animation to perform
  37845. */
  37846. animation: Animation;
  37847. /**
  37848. * Target to animate
  37849. */
  37850. target: any;
  37851. /**
  37852. * Serialize the object
  37853. * @returns the JSON object representing the current entity
  37854. */
  37855. serialize(): any;
  37856. }
  37857. /**
  37858. * Use this class to create coordinated animations on multiple targets
  37859. */
  37860. export class AnimationGroup implements IDisposable {
  37861. /** The name of the animation group */
  37862. name: string;
  37863. private _scene;
  37864. private _targetedAnimations;
  37865. private _animatables;
  37866. private _from;
  37867. private _to;
  37868. private _isStarted;
  37869. private _isPaused;
  37870. private _speedRatio;
  37871. private _loopAnimation;
  37872. private _isAdditive;
  37873. /**
  37874. * Gets or sets the unique id of the node
  37875. */
  37876. uniqueId: number;
  37877. /**
  37878. * This observable will notify when one animation have ended
  37879. */
  37880. onAnimationEndObservable: Observable<TargetedAnimation>;
  37881. /**
  37882. * Observer raised when one animation loops
  37883. */
  37884. onAnimationLoopObservable: Observable<TargetedAnimation>;
  37885. /**
  37886. * Observer raised when all animations have looped
  37887. */
  37888. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  37889. /**
  37890. * This observable will notify when all animations have ended.
  37891. */
  37892. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  37893. /**
  37894. * This observable will notify when all animations have paused.
  37895. */
  37896. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  37897. /**
  37898. * This observable will notify when all animations are playing.
  37899. */
  37900. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  37901. /**
  37902. * Gets the first frame
  37903. */
  37904. get from(): number;
  37905. /**
  37906. * Gets the last frame
  37907. */
  37908. get to(): number;
  37909. /**
  37910. * Define if the animations are started
  37911. */
  37912. get isStarted(): boolean;
  37913. /**
  37914. * Gets a value indicating that the current group is playing
  37915. */
  37916. get isPlaying(): boolean;
  37917. /**
  37918. * Gets or sets the speed ratio to use for all animations
  37919. */
  37920. get speedRatio(): number;
  37921. /**
  37922. * Gets or sets the speed ratio to use for all animations
  37923. */
  37924. set speedRatio(value: number);
  37925. /**
  37926. * Gets or sets if all animations should loop or not
  37927. */
  37928. get loopAnimation(): boolean;
  37929. set loopAnimation(value: boolean);
  37930. /**
  37931. * Gets or sets if all animations should be evaluated additively
  37932. */
  37933. get isAdditive(): boolean;
  37934. set isAdditive(value: boolean);
  37935. /**
  37936. * Gets the targeted animations for this animation group
  37937. */
  37938. get targetedAnimations(): Array<TargetedAnimation>;
  37939. /**
  37940. * returning the list of animatables controlled by this animation group.
  37941. */
  37942. get animatables(): Array<Animatable>;
  37943. /**
  37944. * Instantiates a new Animation Group.
  37945. * This helps managing several animations at once.
  37946. * @see http://doc.babylonjs.com/how_to/group
  37947. * @param name Defines the name of the group
  37948. * @param scene Defines the scene the group belongs to
  37949. */
  37950. constructor(
  37951. /** The name of the animation group */
  37952. name: string, scene?: Nullable<Scene>);
  37953. /**
  37954. * Add an animation (with its target) in the group
  37955. * @param animation defines the animation we want to add
  37956. * @param target defines the target of the animation
  37957. * @returns the TargetedAnimation object
  37958. */
  37959. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  37960. /**
  37961. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  37962. * It can add constant keys at begin or end
  37963. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  37964. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  37965. * @returns the animation group
  37966. */
  37967. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  37968. private _animationLoopCount;
  37969. private _animationLoopFlags;
  37970. private _processLoop;
  37971. /**
  37972. * Start all animations on given targets
  37973. * @param loop defines if animations must loop
  37974. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  37975. * @param from defines the from key (optional)
  37976. * @param to defines the to key (optional)
  37977. * @param isAdditive defines the additive state for the resulting animatables (optional)
  37978. * @returns the current animation group
  37979. */
  37980. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  37981. /**
  37982. * Pause all animations
  37983. * @returns the animation group
  37984. */
  37985. pause(): AnimationGroup;
  37986. /**
  37987. * Play all animations to initial state
  37988. * This function will start() the animations if they were not started or will restart() them if they were paused
  37989. * @param loop defines if animations must loop
  37990. * @returns the animation group
  37991. */
  37992. play(loop?: boolean): AnimationGroup;
  37993. /**
  37994. * Reset all animations to initial state
  37995. * @returns the animation group
  37996. */
  37997. reset(): AnimationGroup;
  37998. /**
  37999. * Restart animations from key 0
  38000. * @returns the animation group
  38001. */
  38002. restart(): AnimationGroup;
  38003. /**
  38004. * Stop all animations
  38005. * @returns the animation group
  38006. */
  38007. stop(): AnimationGroup;
  38008. /**
  38009. * Set animation weight for all animatables
  38010. * @param weight defines the weight to use
  38011. * @return the animationGroup
  38012. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38013. */
  38014. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38015. /**
  38016. * Synchronize and normalize all animatables with a source animatable
  38017. * @param root defines the root animatable to synchronize with
  38018. * @return the animationGroup
  38019. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38020. */
  38021. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38022. /**
  38023. * Goes to a specific frame in this animation group
  38024. * @param frame the frame number to go to
  38025. * @return the animationGroup
  38026. */
  38027. goToFrame(frame: number): AnimationGroup;
  38028. /**
  38029. * Dispose all associated resources
  38030. */
  38031. dispose(): void;
  38032. private _checkAnimationGroupEnded;
  38033. /**
  38034. * Clone the current animation group and returns a copy
  38035. * @param newName defines the name of the new group
  38036. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38037. * @returns the new aniamtion group
  38038. */
  38039. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38040. /**
  38041. * Serializes the animationGroup to an object
  38042. * @returns Serialized object
  38043. */
  38044. serialize(): any;
  38045. /**
  38046. * Returns a new AnimationGroup object parsed from the source provided.
  38047. * @param parsedAnimationGroup defines the source
  38048. * @param scene defines the scene that will receive the animationGroup
  38049. * @returns a new AnimationGroup
  38050. */
  38051. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38052. /**
  38053. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38054. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38055. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38056. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38057. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38058. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38059. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38060. */
  38061. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38062. /**
  38063. * Returns the string "AnimationGroup"
  38064. * @returns "AnimationGroup"
  38065. */
  38066. getClassName(): string;
  38067. /**
  38068. * Creates a detailled string about the object
  38069. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38070. * @returns a string representing the object
  38071. */
  38072. toString(fullDetails?: boolean): string;
  38073. }
  38074. }
  38075. declare module BABYLON {
  38076. /**
  38077. * Define an interface for all classes that will hold resources
  38078. */
  38079. export interface IDisposable {
  38080. /**
  38081. * Releases all held resources
  38082. */
  38083. dispose(): void;
  38084. }
  38085. /** Interface defining initialization parameters for Scene class */
  38086. export interface SceneOptions {
  38087. /**
  38088. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38089. * It will improve performance when the number of geometries becomes important.
  38090. */
  38091. useGeometryUniqueIdsMap?: boolean;
  38092. /**
  38093. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38094. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38095. */
  38096. useMaterialMeshMap?: boolean;
  38097. /**
  38098. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38099. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38100. */
  38101. useClonedMeshMap?: boolean;
  38102. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38103. virtual?: boolean;
  38104. }
  38105. /**
  38106. * Represents a scene to be rendered by the engine.
  38107. * @see http://doc.babylonjs.com/features/scene
  38108. */
  38109. export class Scene extends AbstractScene implements IAnimatable {
  38110. /** The fog is deactivated */
  38111. static readonly FOGMODE_NONE: number;
  38112. /** The fog density is following an exponential function */
  38113. static readonly FOGMODE_EXP: number;
  38114. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38115. static readonly FOGMODE_EXP2: number;
  38116. /** The fog density is following a linear function. */
  38117. static readonly FOGMODE_LINEAR: number;
  38118. /**
  38119. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38120. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38121. */
  38122. static MinDeltaTime: number;
  38123. /**
  38124. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38125. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38126. */
  38127. static MaxDeltaTime: number;
  38128. /**
  38129. * Factory used to create the default material.
  38130. * @param name The name of the material to create
  38131. * @param scene The scene to create the material for
  38132. * @returns The default material
  38133. */
  38134. static DefaultMaterialFactory(scene: Scene): Material;
  38135. /**
  38136. * Factory used to create the a collision coordinator.
  38137. * @returns The collision coordinator
  38138. */
  38139. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38140. /** @hidden */
  38141. _inputManager: InputManager;
  38142. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38143. cameraToUseForPointers: Nullable<Camera>;
  38144. /** @hidden */
  38145. readonly _isScene: boolean;
  38146. /** @hidden */
  38147. _blockEntityCollection: boolean;
  38148. /**
  38149. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38150. */
  38151. autoClear: boolean;
  38152. /**
  38153. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38154. */
  38155. autoClearDepthAndStencil: boolean;
  38156. /**
  38157. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38158. */
  38159. clearColor: Color4;
  38160. /**
  38161. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38162. */
  38163. ambientColor: Color3;
  38164. /**
  38165. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38166. * It should only be one of the following (if not the default embedded one):
  38167. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38168. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38169. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38170. * The material properties need to be setup according to the type of texture in use.
  38171. */
  38172. environmentBRDFTexture: BaseTexture;
  38173. /** @hidden */
  38174. protected _environmentTexture: Nullable<BaseTexture>;
  38175. /**
  38176. * Texture used in all pbr material as the reflection texture.
  38177. * As in the majority of the scene they are the same (exception for multi room and so on),
  38178. * this is easier to reference from here than from all the materials.
  38179. */
  38180. get environmentTexture(): Nullable<BaseTexture>;
  38181. /**
  38182. * Texture used in all pbr material as the reflection texture.
  38183. * As in the majority of the scene they are the same (exception for multi room and so on),
  38184. * this is easier to set here than in all the materials.
  38185. */
  38186. set environmentTexture(value: Nullable<BaseTexture>);
  38187. /** @hidden */
  38188. protected _environmentIntensity: number;
  38189. /**
  38190. * Intensity of the environment in all pbr material.
  38191. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38192. * As in the majority of the scene they are the same (exception for multi room and so on),
  38193. * this is easier to reference from here than from all the materials.
  38194. */
  38195. get environmentIntensity(): number;
  38196. /**
  38197. * Intensity of the environment in all pbr material.
  38198. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38199. * As in the majority of the scene they are the same (exception for multi room and so on),
  38200. * this is easier to set here than in all the materials.
  38201. */
  38202. set environmentIntensity(value: number);
  38203. /** @hidden */
  38204. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38205. /**
  38206. * Default image processing configuration used either in the rendering
  38207. * Forward main pass or through the imageProcessingPostProcess if present.
  38208. * As in the majority of the scene they are the same (exception for multi camera),
  38209. * this is easier to reference from here than from all the materials and post process.
  38210. *
  38211. * No setter as we it is a shared configuration, you can set the values instead.
  38212. */
  38213. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38214. private _forceWireframe;
  38215. /**
  38216. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38217. */
  38218. set forceWireframe(value: boolean);
  38219. get forceWireframe(): boolean;
  38220. private _skipFrustumClipping;
  38221. /**
  38222. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38223. */
  38224. set skipFrustumClipping(value: boolean);
  38225. get skipFrustumClipping(): boolean;
  38226. private _forcePointsCloud;
  38227. /**
  38228. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38229. */
  38230. set forcePointsCloud(value: boolean);
  38231. get forcePointsCloud(): boolean;
  38232. /**
  38233. * Gets or sets the active clipplane 1
  38234. */
  38235. clipPlane: Nullable<Plane>;
  38236. /**
  38237. * Gets or sets the active clipplane 2
  38238. */
  38239. clipPlane2: Nullable<Plane>;
  38240. /**
  38241. * Gets or sets the active clipplane 3
  38242. */
  38243. clipPlane3: Nullable<Plane>;
  38244. /**
  38245. * Gets or sets the active clipplane 4
  38246. */
  38247. clipPlane4: Nullable<Plane>;
  38248. /**
  38249. * Gets or sets the active clipplane 5
  38250. */
  38251. clipPlane5: Nullable<Plane>;
  38252. /**
  38253. * Gets or sets the active clipplane 6
  38254. */
  38255. clipPlane6: Nullable<Plane>;
  38256. /**
  38257. * Gets or sets a boolean indicating if animations are enabled
  38258. */
  38259. animationsEnabled: boolean;
  38260. private _animationPropertiesOverride;
  38261. /**
  38262. * Gets or sets the animation properties override
  38263. */
  38264. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38265. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38266. /**
  38267. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38268. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38269. */
  38270. useConstantAnimationDeltaTime: boolean;
  38271. /**
  38272. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38273. * Please note that it requires to run a ray cast through the scene on every frame
  38274. */
  38275. constantlyUpdateMeshUnderPointer: boolean;
  38276. /**
  38277. * Defines the HTML cursor to use when hovering over interactive elements
  38278. */
  38279. hoverCursor: string;
  38280. /**
  38281. * Defines the HTML default cursor to use (empty by default)
  38282. */
  38283. defaultCursor: string;
  38284. /**
  38285. * Defines whether cursors are handled by the scene.
  38286. */
  38287. doNotHandleCursors: boolean;
  38288. /**
  38289. * This is used to call preventDefault() on pointer down
  38290. * in order to block unwanted artifacts like system double clicks
  38291. */
  38292. preventDefaultOnPointerDown: boolean;
  38293. /**
  38294. * This is used to call preventDefault() on pointer up
  38295. * in order to block unwanted artifacts like system double clicks
  38296. */
  38297. preventDefaultOnPointerUp: boolean;
  38298. /**
  38299. * Gets or sets user defined metadata
  38300. */
  38301. metadata: any;
  38302. /**
  38303. * For internal use only. Please do not use.
  38304. */
  38305. reservedDataStore: any;
  38306. /**
  38307. * Gets the name of the plugin used to load this scene (null by default)
  38308. */
  38309. loadingPluginName: string;
  38310. /**
  38311. * Use this array to add regular expressions used to disable offline support for specific urls
  38312. */
  38313. disableOfflineSupportExceptionRules: RegExp[];
  38314. /**
  38315. * An event triggered when the scene is disposed.
  38316. */
  38317. onDisposeObservable: Observable<Scene>;
  38318. private _onDisposeObserver;
  38319. /** Sets a function to be executed when this scene is disposed. */
  38320. set onDispose(callback: () => void);
  38321. /**
  38322. * An event triggered before rendering the scene (right after animations and physics)
  38323. */
  38324. onBeforeRenderObservable: Observable<Scene>;
  38325. private _onBeforeRenderObserver;
  38326. /** Sets a function to be executed before rendering this scene */
  38327. set beforeRender(callback: Nullable<() => void>);
  38328. /**
  38329. * An event triggered after rendering the scene
  38330. */
  38331. onAfterRenderObservable: Observable<Scene>;
  38332. /**
  38333. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38334. */
  38335. onAfterRenderCameraObservable: Observable<Camera>;
  38336. private _onAfterRenderObserver;
  38337. /** Sets a function to be executed after rendering this scene */
  38338. set afterRender(callback: Nullable<() => void>);
  38339. /**
  38340. * An event triggered before animating the scene
  38341. */
  38342. onBeforeAnimationsObservable: Observable<Scene>;
  38343. /**
  38344. * An event triggered after animations processing
  38345. */
  38346. onAfterAnimationsObservable: Observable<Scene>;
  38347. /**
  38348. * An event triggered before draw calls are ready to be sent
  38349. */
  38350. onBeforeDrawPhaseObservable: Observable<Scene>;
  38351. /**
  38352. * An event triggered after draw calls have been sent
  38353. */
  38354. onAfterDrawPhaseObservable: Observable<Scene>;
  38355. /**
  38356. * An event triggered when the scene is ready
  38357. */
  38358. onReadyObservable: Observable<Scene>;
  38359. /**
  38360. * An event triggered before rendering a camera
  38361. */
  38362. onBeforeCameraRenderObservable: Observable<Camera>;
  38363. private _onBeforeCameraRenderObserver;
  38364. /** Sets a function to be executed before rendering a camera*/
  38365. set beforeCameraRender(callback: () => void);
  38366. /**
  38367. * An event triggered after rendering a camera
  38368. */
  38369. onAfterCameraRenderObservable: Observable<Camera>;
  38370. private _onAfterCameraRenderObserver;
  38371. /** Sets a function to be executed after rendering a camera*/
  38372. set afterCameraRender(callback: () => void);
  38373. /**
  38374. * An event triggered when active meshes evaluation is about to start
  38375. */
  38376. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38377. /**
  38378. * An event triggered when active meshes evaluation is done
  38379. */
  38380. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38381. /**
  38382. * An event triggered when particles rendering is about to start
  38383. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38384. */
  38385. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38386. /**
  38387. * An event triggered when particles rendering is done
  38388. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38389. */
  38390. onAfterParticlesRenderingObservable: Observable<Scene>;
  38391. /**
  38392. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38393. */
  38394. onDataLoadedObservable: Observable<Scene>;
  38395. /**
  38396. * An event triggered when a camera is created
  38397. */
  38398. onNewCameraAddedObservable: Observable<Camera>;
  38399. /**
  38400. * An event triggered when a camera is removed
  38401. */
  38402. onCameraRemovedObservable: Observable<Camera>;
  38403. /**
  38404. * An event triggered when a light is created
  38405. */
  38406. onNewLightAddedObservable: Observable<Light>;
  38407. /**
  38408. * An event triggered when a light is removed
  38409. */
  38410. onLightRemovedObservable: Observable<Light>;
  38411. /**
  38412. * An event triggered when a geometry is created
  38413. */
  38414. onNewGeometryAddedObservable: Observable<Geometry>;
  38415. /**
  38416. * An event triggered when a geometry is removed
  38417. */
  38418. onGeometryRemovedObservable: Observable<Geometry>;
  38419. /**
  38420. * An event triggered when a transform node is created
  38421. */
  38422. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38423. /**
  38424. * An event triggered when a transform node is removed
  38425. */
  38426. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38427. /**
  38428. * An event triggered when a mesh is created
  38429. */
  38430. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38431. /**
  38432. * An event triggered when a mesh is removed
  38433. */
  38434. onMeshRemovedObservable: Observable<AbstractMesh>;
  38435. /**
  38436. * An event triggered when a skeleton is created
  38437. */
  38438. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38439. /**
  38440. * An event triggered when a skeleton is removed
  38441. */
  38442. onSkeletonRemovedObservable: Observable<Skeleton>;
  38443. /**
  38444. * An event triggered when a material is created
  38445. */
  38446. onNewMaterialAddedObservable: Observable<Material>;
  38447. /**
  38448. * An event triggered when a material is removed
  38449. */
  38450. onMaterialRemovedObservable: Observable<Material>;
  38451. /**
  38452. * An event triggered when a texture is created
  38453. */
  38454. onNewTextureAddedObservable: Observable<BaseTexture>;
  38455. /**
  38456. * An event triggered when a texture is removed
  38457. */
  38458. onTextureRemovedObservable: Observable<BaseTexture>;
  38459. /**
  38460. * An event triggered when render targets are about to be rendered
  38461. * Can happen multiple times per frame.
  38462. */
  38463. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38464. /**
  38465. * An event triggered when render targets were rendered.
  38466. * Can happen multiple times per frame.
  38467. */
  38468. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38469. /**
  38470. * An event triggered before calculating deterministic simulation step
  38471. */
  38472. onBeforeStepObservable: Observable<Scene>;
  38473. /**
  38474. * An event triggered after calculating deterministic simulation step
  38475. */
  38476. onAfterStepObservable: Observable<Scene>;
  38477. /**
  38478. * An event triggered when the activeCamera property is updated
  38479. */
  38480. onActiveCameraChanged: Observable<Scene>;
  38481. /**
  38482. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38483. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38484. * 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)
  38485. */
  38486. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38487. /**
  38488. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38489. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38490. * 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)
  38491. */
  38492. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38493. /**
  38494. * This Observable will when a mesh has been imported into the scene.
  38495. */
  38496. onMeshImportedObservable: Observable<AbstractMesh>;
  38497. /**
  38498. * This Observable will when an animation file has been imported into the scene.
  38499. */
  38500. onAnimationFileImportedObservable: Observable<Scene>;
  38501. /**
  38502. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38503. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38504. */
  38505. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38506. /** @hidden */
  38507. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38508. /**
  38509. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38510. */
  38511. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38512. /**
  38513. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38514. */
  38515. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38516. /**
  38517. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38518. */
  38519. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38520. /** Callback called when a pointer move is detected */
  38521. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38522. /** Callback called when a pointer down is detected */
  38523. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38524. /** Callback called when a pointer up is detected */
  38525. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38526. /** Callback called when a pointer pick is detected */
  38527. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38528. /**
  38529. * 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).
  38530. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38531. */
  38532. onPrePointerObservable: Observable<PointerInfoPre>;
  38533. /**
  38534. * Observable event triggered each time an input event is received from the rendering canvas
  38535. */
  38536. onPointerObservable: Observable<PointerInfo>;
  38537. /**
  38538. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38539. */
  38540. get unTranslatedPointer(): Vector2;
  38541. /**
  38542. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38543. */
  38544. static get DragMovementThreshold(): number;
  38545. static set DragMovementThreshold(value: number);
  38546. /**
  38547. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38548. */
  38549. static get LongPressDelay(): number;
  38550. static set LongPressDelay(value: number);
  38551. /**
  38552. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38553. */
  38554. static get DoubleClickDelay(): number;
  38555. static set DoubleClickDelay(value: number);
  38556. /** If you need to check double click without raising a single click at first click, enable this flag */
  38557. static get ExclusiveDoubleClickMode(): boolean;
  38558. static set ExclusiveDoubleClickMode(value: boolean);
  38559. /** @hidden */
  38560. _mirroredCameraPosition: Nullable<Vector3>;
  38561. /**
  38562. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38563. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38564. */
  38565. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38566. /**
  38567. * Observable event triggered each time an keyboard event is received from the hosting window
  38568. */
  38569. onKeyboardObservable: Observable<KeyboardInfo>;
  38570. private _useRightHandedSystem;
  38571. /**
  38572. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38573. */
  38574. set useRightHandedSystem(value: boolean);
  38575. get useRightHandedSystem(): boolean;
  38576. private _timeAccumulator;
  38577. private _currentStepId;
  38578. private _currentInternalStep;
  38579. /**
  38580. * Sets the step Id used by deterministic lock step
  38581. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38582. * @param newStepId defines the step Id
  38583. */
  38584. setStepId(newStepId: number): void;
  38585. /**
  38586. * Gets the step Id used by deterministic lock step
  38587. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38588. * @returns the step Id
  38589. */
  38590. getStepId(): number;
  38591. /**
  38592. * Gets the internal step used by deterministic lock step
  38593. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38594. * @returns the internal step
  38595. */
  38596. getInternalStep(): number;
  38597. private _fogEnabled;
  38598. /**
  38599. * Gets or sets a boolean indicating if fog is enabled on this scene
  38600. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38601. * (Default is true)
  38602. */
  38603. set fogEnabled(value: boolean);
  38604. get fogEnabled(): boolean;
  38605. private _fogMode;
  38606. /**
  38607. * Gets or sets the fog mode to use
  38608. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38609. * | mode | value |
  38610. * | --- | --- |
  38611. * | FOGMODE_NONE | 0 |
  38612. * | FOGMODE_EXP | 1 |
  38613. * | FOGMODE_EXP2 | 2 |
  38614. * | FOGMODE_LINEAR | 3 |
  38615. */
  38616. set fogMode(value: number);
  38617. get fogMode(): number;
  38618. /**
  38619. * Gets or sets the fog color to use
  38620. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38621. * (Default is Color3(0.2, 0.2, 0.3))
  38622. */
  38623. fogColor: Color3;
  38624. /**
  38625. * Gets or sets the fog density to use
  38626. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38627. * (Default is 0.1)
  38628. */
  38629. fogDensity: number;
  38630. /**
  38631. * Gets or sets the fog start distance to use
  38632. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38633. * (Default is 0)
  38634. */
  38635. fogStart: number;
  38636. /**
  38637. * Gets or sets the fog end distance to use
  38638. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38639. * (Default is 1000)
  38640. */
  38641. fogEnd: number;
  38642. private _shadowsEnabled;
  38643. /**
  38644. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38645. */
  38646. set shadowsEnabled(value: boolean);
  38647. get shadowsEnabled(): boolean;
  38648. private _lightsEnabled;
  38649. /**
  38650. * Gets or sets a boolean indicating if lights are enabled on this scene
  38651. */
  38652. set lightsEnabled(value: boolean);
  38653. get lightsEnabled(): boolean;
  38654. /** All of the active cameras added to this scene. */
  38655. activeCameras: Camera[];
  38656. /** @hidden */
  38657. _activeCamera: Nullable<Camera>;
  38658. /** Gets or sets the current active camera */
  38659. get activeCamera(): Nullable<Camera>;
  38660. set activeCamera(value: Nullable<Camera>);
  38661. private _defaultMaterial;
  38662. /** The default material used on meshes when no material is affected */
  38663. get defaultMaterial(): Material;
  38664. /** The default material used on meshes when no material is affected */
  38665. set defaultMaterial(value: Material);
  38666. private _texturesEnabled;
  38667. /**
  38668. * Gets or sets a boolean indicating if textures are enabled on this scene
  38669. */
  38670. set texturesEnabled(value: boolean);
  38671. get texturesEnabled(): boolean;
  38672. /**
  38673. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38674. */
  38675. physicsEnabled: boolean;
  38676. /**
  38677. * Gets or sets a boolean indicating if particles are enabled on this scene
  38678. */
  38679. particlesEnabled: boolean;
  38680. /**
  38681. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38682. */
  38683. spritesEnabled: boolean;
  38684. private _skeletonsEnabled;
  38685. /**
  38686. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38687. */
  38688. set skeletonsEnabled(value: boolean);
  38689. get skeletonsEnabled(): boolean;
  38690. /**
  38691. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38692. */
  38693. lensFlaresEnabled: boolean;
  38694. /**
  38695. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38696. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38697. */
  38698. collisionsEnabled: boolean;
  38699. private _collisionCoordinator;
  38700. /** @hidden */
  38701. get collisionCoordinator(): ICollisionCoordinator;
  38702. /**
  38703. * Defines the gravity applied to this scene (used only for collisions)
  38704. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38705. */
  38706. gravity: Vector3;
  38707. /**
  38708. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38709. */
  38710. postProcessesEnabled: boolean;
  38711. /**
  38712. * The list of postprocesses added to the scene
  38713. */
  38714. postProcesses: PostProcess[];
  38715. /**
  38716. * Gets the current postprocess manager
  38717. */
  38718. postProcessManager: PostProcessManager;
  38719. /**
  38720. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38721. */
  38722. renderTargetsEnabled: boolean;
  38723. /**
  38724. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38725. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38726. */
  38727. dumpNextRenderTargets: boolean;
  38728. /**
  38729. * The list of user defined render targets added to the scene
  38730. */
  38731. customRenderTargets: RenderTargetTexture[];
  38732. /**
  38733. * Defines if texture loading must be delayed
  38734. * If true, textures will only be loaded when they need to be rendered
  38735. */
  38736. useDelayedTextureLoading: boolean;
  38737. /**
  38738. * Gets the list of meshes imported to the scene through SceneLoader
  38739. */
  38740. importedMeshesFiles: String[];
  38741. /**
  38742. * Gets or sets a boolean indicating if probes are enabled on this scene
  38743. */
  38744. probesEnabled: boolean;
  38745. /**
  38746. * Gets or sets the current offline provider to use to store scene data
  38747. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38748. */
  38749. offlineProvider: IOfflineProvider;
  38750. /**
  38751. * Gets or sets the action manager associated with the scene
  38752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38753. */
  38754. actionManager: AbstractActionManager;
  38755. private _meshesForIntersections;
  38756. /**
  38757. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38758. */
  38759. proceduralTexturesEnabled: boolean;
  38760. private _engine;
  38761. private _totalVertices;
  38762. /** @hidden */
  38763. _activeIndices: PerfCounter;
  38764. /** @hidden */
  38765. _activeParticles: PerfCounter;
  38766. /** @hidden */
  38767. _activeBones: PerfCounter;
  38768. private _animationRatio;
  38769. /** @hidden */
  38770. _animationTimeLast: number;
  38771. /** @hidden */
  38772. _animationTime: number;
  38773. /**
  38774. * Gets or sets a general scale for animation speed
  38775. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38776. */
  38777. animationTimeScale: number;
  38778. /** @hidden */
  38779. _cachedMaterial: Nullable<Material>;
  38780. /** @hidden */
  38781. _cachedEffect: Nullable<Effect>;
  38782. /** @hidden */
  38783. _cachedVisibility: Nullable<number>;
  38784. private _renderId;
  38785. private _frameId;
  38786. private _executeWhenReadyTimeoutId;
  38787. private _intermediateRendering;
  38788. private _viewUpdateFlag;
  38789. private _projectionUpdateFlag;
  38790. /** @hidden */
  38791. _toBeDisposed: Nullable<IDisposable>[];
  38792. private _activeRequests;
  38793. /** @hidden */
  38794. _pendingData: any[];
  38795. private _isDisposed;
  38796. /**
  38797. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  38798. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  38799. */
  38800. dispatchAllSubMeshesOfActiveMeshes: boolean;
  38801. private _activeMeshes;
  38802. private _processedMaterials;
  38803. private _renderTargets;
  38804. /** @hidden */
  38805. _activeParticleSystems: SmartArray<IParticleSystem>;
  38806. private _activeSkeletons;
  38807. private _softwareSkinnedMeshes;
  38808. private _renderingManager;
  38809. /** @hidden */
  38810. _activeAnimatables: Animatable[];
  38811. private _transformMatrix;
  38812. private _sceneUbo;
  38813. /** @hidden */
  38814. _viewMatrix: Matrix;
  38815. private _projectionMatrix;
  38816. /** @hidden */
  38817. _forcedViewPosition: Nullable<Vector3>;
  38818. /** @hidden */
  38819. _frustumPlanes: Plane[];
  38820. /**
  38821. * Gets the list of frustum planes (built from the active camera)
  38822. */
  38823. get frustumPlanes(): Plane[];
  38824. /**
  38825. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  38826. * This is useful if there are more lights that the maximum simulteanous authorized
  38827. */
  38828. requireLightSorting: boolean;
  38829. /** @hidden */
  38830. readonly useMaterialMeshMap: boolean;
  38831. /** @hidden */
  38832. readonly useClonedMeshMap: boolean;
  38833. private _externalData;
  38834. private _uid;
  38835. /**
  38836. * @hidden
  38837. * Backing store of defined scene components.
  38838. */
  38839. _components: ISceneComponent[];
  38840. /**
  38841. * @hidden
  38842. * Backing store of defined scene components.
  38843. */
  38844. _serializableComponents: ISceneSerializableComponent[];
  38845. /**
  38846. * List of components to register on the next registration step.
  38847. */
  38848. private _transientComponents;
  38849. /**
  38850. * Registers the transient components if needed.
  38851. */
  38852. private _registerTransientComponents;
  38853. /**
  38854. * @hidden
  38855. * Add a component to the scene.
  38856. * Note that the ccomponent could be registered on th next frame if this is called after
  38857. * the register component stage.
  38858. * @param component Defines the component to add to the scene
  38859. */
  38860. _addComponent(component: ISceneComponent): void;
  38861. /**
  38862. * @hidden
  38863. * Gets a component from the scene.
  38864. * @param name defines the name of the component to retrieve
  38865. * @returns the component or null if not present
  38866. */
  38867. _getComponent(name: string): Nullable<ISceneComponent>;
  38868. /**
  38869. * @hidden
  38870. * Defines the actions happening before camera updates.
  38871. */
  38872. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  38873. /**
  38874. * @hidden
  38875. * Defines the actions happening before clear the canvas.
  38876. */
  38877. _beforeClearStage: Stage<SimpleStageAction>;
  38878. /**
  38879. * @hidden
  38880. * Defines the actions when collecting render targets for the frame.
  38881. */
  38882. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38883. /**
  38884. * @hidden
  38885. * Defines the actions happening for one camera in the frame.
  38886. */
  38887. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38888. /**
  38889. * @hidden
  38890. * Defines the actions happening during the per mesh ready checks.
  38891. */
  38892. _isReadyForMeshStage: Stage<MeshStageAction>;
  38893. /**
  38894. * @hidden
  38895. * Defines the actions happening before evaluate active mesh checks.
  38896. */
  38897. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  38898. /**
  38899. * @hidden
  38900. * Defines the actions happening during the evaluate sub mesh checks.
  38901. */
  38902. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  38903. /**
  38904. * @hidden
  38905. * Defines the actions happening during the active mesh stage.
  38906. */
  38907. _activeMeshStage: Stage<ActiveMeshStageAction>;
  38908. /**
  38909. * @hidden
  38910. * Defines the actions happening during the per camera render target step.
  38911. */
  38912. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  38913. /**
  38914. * @hidden
  38915. * Defines the actions happening just before the active camera is drawing.
  38916. */
  38917. _beforeCameraDrawStage: Stage<CameraStageAction>;
  38918. /**
  38919. * @hidden
  38920. * Defines the actions happening just before a render target is drawing.
  38921. */
  38922. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38923. /**
  38924. * @hidden
  38925. * Defines the actions happening just before a rendering group is drawing.
  38926. */
  38927. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38928. /**
  38929. * @hidden
  38930. * Defines the actions happening just before a mesh is drawing.
  38931. */
  38932. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38933. /**
  38934. * @hidden
  38935. * Defines the actions happening just after a mesh has been drawn.
  38936. */
  38937. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38938. /**
  38939. * @hidden
  38940. * Defines the actions happening just after a rendering group has been drawn.
  38941. */
  38942. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38943. /**
  38944. * @hidden
  38945. * Defines the actions happening just after the active camera has been drawn.
  38946. */
  38947. _afterCameraDrawStage: Stage<CameraStageAction>;
  38948. /**
  38949. * @hidden
  38950. * Defines the actions happening just after a render target has been drawn.
  38951. */
  38952. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38953. /**
  38954. * @hidden
  38955. * Defines the actions happening just after rendering all cameras and computing intersections.
  38956. */
  38957. _afterRenderStage: Stage<SimpleStageAction>;
  38958. /**
  38959. * @hidden
  38960. * Defines the actions happening when a pointer move event happens.
  38961. */
  38962. _pointerMoveStage: Stage<PointerMoveStageAction>;
  38963. /**
  38964. * @hidden
  38965. * Defines the actions happening when a pointer down event happens.
  38966. */
  38967. _pointerDownStage: Stage<PointerUpDownStageAction>;
  38968. /**
  38969. * @hidden
  38970. * Defines the actions happening when a pointer up event happens.
  38971. */
  38972. _pointerUpStage: Stage<PointerUpDownStageAction>;
  38973. /**
  38974. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  38975. */
  38976. private geometriesByUniqueId;
  38977. /**
  38978. * Creates a new Scene
  38979. * @param engine defines the engine to use to render this scene
  38980. * @param options defines the scene options
  38981. */
  38982. constructor(engine: Engine, options?: SceneOptions);
  38983. /**
  38984. * Gets a string idenfifying the name of the class
  38985. * @returns "Scene" string
  38986. */
  38987. getClassName(): string;
  38988. private _defaultMeshCandidates;
  38989. /**
  38990. * @hidden
  38991. */
  38992. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  38993. private _defaultSubMeshCandidates;
  38994. /**
  38995. * @hidden
  38996. */
  38997. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  38998. /**
  38999. * Sets the default candidate providers for the scene.
  39000. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39001. * and getCollidingSubMeshCandidates to their default function
  39002. */
  39003. setDefaultCandidateProviders(): void;
  39004. /**
  39005. * Gets the mesh that is currently under the pointer
  39006. */
  39007. get meshUnderPointer(): Nullable<AbstractMesh>;
  39008. /**
  39009. * Gets or sets the current on-screen X position of the pointer
  39010. */
  39011. get pointerX(): number;
  39012. set pointerX(value: number);
  39013. /**
  39014. * Gets or sets the current on-screen Y position of the pointer
  39015. */
  39016. get pointerY(): number;
  39017. set pointerY(value: number);
  39018. /**
  39019. * Gets the cached material (ie. the latest rendered one)
  39020. * @returns the cached material
  39021. */
  39022. getCachedMaterial(): Nullable<Material>;
  39023. /**
  39024. * Gets the cached effect (ie. the latest rendered one)
  39025. * @returns the cached effect
  39026. */
  39027. getCachedEffect(): Nullable<Effect>;
  39028. /**
  39029. * Gets the cached visibility state (ie. the latest rendered one)
  39030. * @returns the cached visibility state
  39031. */
  39032. getCachedVisibility(): Nullable<number>;
  39033. /**
  39034. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39035. * @param material defines the current material
  39036. * @param effect defines the current effect
  39037. * @param visibility defines the current visibility state
  39038. * @returns true if one parameter is not cached
  39039. */
  39040. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39041. /**
  39042. * Gets the engine associated with the scene
  39043. * @returns an Engine
  39044. */
  39045. getEngine(): Engine;
  39046. /**
  39047. * Gets the total number of vertices rendered per frame
  39048. * @returns the total number of vertices rendered per frame
  39049. */
  39050. getTotalVertices(): number;
  39051. /**
  39052. * Gets the performance counter for total vertices
  39053. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39054. */
  39055. get totalVerticesPerfCounter(): PerfCounter;
  39056. /**
  39057. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39058. * @returns the total number of active indices rendered per frame
  39059. */
  39060. getActiveIndices(): number;
  39061. /**
  39062. * Gets the performance counter for active indices
  39063. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39064. */
  39065. get totalActiveIndicesPerfCounter(): PerfCounter;
  39066. /**
  39067. * Gets the total number of active particles rendered per frame
  39068. * @returns the total number of active particles rendered per frame
  39069. */
  39070. getActiveParticles(): number;
  39071. /**
  39072. * Gets the performance counter for active particles
  39073. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39074. */
  39075. get activeParticlesPerfCounter(): PerfCounter;
  39076. /**
  39077. * Gets the total number of active bones rendered per frame
  39078. * @returns the total number of active bones rendered per frame
  39079. */
  39080. getActiveBones(): number;
  39081. /**
  39082. * Gets the performance counter for active bones
  39083. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39084. */
  39085. get activeBonesPerfCounter(): PerfCounter;
  39086. /**
  39087. * Gets the array of active meshes
  39088. * @returns an array of AbstractMesh
  39089. */
  39090. getActiveMeshes(): SmartArray<AbstractMesh>;
  39091. /**
  39092. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39093. * @returns a number
  39094. */
  39095. getAnimationRatio(): number;
  39096. /**
  39097. * Gets an unique Id for the current render phase
  39098. * @returns a number
  39099. */
  39100. getRenderId(): number;
  39101. /**
  39102. * Gets an unique Id for the current frame
  39103. * @returns a number
  39104. */
  39105. getFrameId(): number;
  39106. /** Call this function if you want to manually increment the render Id*/
  39107. incrementRenderId(): void;
  39108. private _createUbo;
  39109. /**
  39110. * Use this method to simulate a pointer move on a mesh
  39111. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39112. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39113. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39114. * @returns the current scene
  39115. */
  39116. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39117. /**
  39118. * Use this method to simulate a pointer down on a mesh
  39119. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39120. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39121. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39122. * @returns the current scene
  39123. */
  39124. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39125. /**
  39126. * Use this method to simulate a pointer up on a mesh
  39127. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39128. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39129. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39130. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39131. * @returns the current scene
  39132. */
  39133. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39134. /**
  39135. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39136. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39137. * @returns true if the pointer was captured
  39138. */
  39139. isPointerCaptured(pointerId?: number): boolean;
  39140. /**
  39141. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39142. * @param attachUp defines if you want to attach events to pointerup
  39143. * @param attachDown defines if you want to attach events to pointerdown
  39144. * @param attachMove defines if you want to attach events to pointermove
  39145. */
  39146. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39147. /** Detaches all event handlers*/
  39148. detachControl(): void;
  39149. /**
  39150. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39151. * Delay loaded resources are not taking in account
  39152. * @return true if all required resources are ready
  39153. */
  39154. isReady(): boolean;
  39155. /** Resets all cached information relative to material (including effect and visibility) */
  39156. resetCachedMaterial(): void;
  39157. /**
  39158. * Registers a function to be called before every frame render
  39159. * @param func defines the function to register
  39160. */
  39161. registerBeforeRender(func: () => void): void;
  39162. /**
  39163. * Unregisters a function called before every frame render
  39164. * @param func defines the function to unregister
  39165. */
  39166. unregisterBeforeRender(func: () => void): void;
  39167. /**
  39168. * Registers a function to be called after every frame render
  39169. * @param func defines the function to register
  39170. */
  39171. registerAfterRender(func: () => void): void;
  39172. /**
  39173. * Unregisters a function called after every frame render
  39174. * @param func defines the function to unregister
  39175. */
  39176. unregisterAfterRender(func: () => void): void;
  39177. private _executeOnceBeforeRender;
  39178. /**
  39179. * The provided function will run before render once and will be disposed afterwards.
  39180. * A timeout delay can be provided so that the function will be executed in N ms.
  39181. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39182. * @param func The function to be executed.
  39183. * @param timeout optional delay in ms
  39184. */
  39185. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39186. /** @hidden */
  39187. _addPendingData(data: any): void;
  39188. /** @hidden */
  39189. _removePendingData(data: any): void;
  39190. /**
  39191. * Returns the number of items waiting to be loaded
  39192. * @returns the number of items waiting to be loaded
  39193. */
  39194. getWaitingItemsCount(): number;
  39195. /**
  39196. * Returns a boolean indicating if the scene is still loading data
  39197. */
  39198. get isLoading(): boolean;
  39199. /**
  39200. * Registers a function to be executed when the scene is ready
  39201. * @param {Function} func - the function to be executed
  39202. */
  39203. executeWhenReady(func: () => void): void;
  39204. /**
  39205. * Returns a promise that resolves when the scene is ready
  39206. * @returns A promise that resolves when the scene is ready
  39207. */
  39208. whenReadyAsync(): Promise<void>;
  39209. /** @hidden */
  39210. _checkIsReady(): void;
  39211. /**
  39212. * Gets all animatable attached to the scene
  39213. */
  39214. get animatables(): Animatable[];
  39215. /**
  39216. * Resets the last animation time frame.
  39217. * Useful to override when animations start running when loading a scene for the first time.
  39218. */
  39219. resetLastAnimationTimeFrame(): void;
  39220. /**
  39221. * Gets the current view matrix
  39222. * @returns a Matrix
  39223. */
  39224. getViewMatrix(): Matrix;
  39225. /**
  39226. * Gets the current projection matrix
  39227. * @returns a Matrix
  39228. */
  39229. getProjectionMatrix(): Matrix;
  39230. /**
  39231. * Gets the current transform matrix
  39232. * @returns a Matrix made of View * Projection
  39233. */
  39234. getTransformMatrix(): Matrix;
  39235. /**
  39236. * Sets the current transform matrix
  39237. * @param viewL defines the View matrix to use
  39238. * @param projectionL defines the Projection matrix to use
  39239. * @param viewR defines the right View matrix to use (if provided)
  39240. * @param projectionR defines the right Projection matrix to use (if provided)
  39241. */
  39242. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39243. /**
  39244. * Gets the uniform buffer used to store scene data
  39245. * @returns a UniformBuffer
  39246. */
  39247. getSceneUniformBuffer(): UniformBuffer;
  39248. /**
  39249. * Gets an unique (relatively to the current scene) Id
  39250. * @returns an unique number for the scene
  39251. */
  39252. getUniqueId(): number;
  39253. /**
  39254. * Add a mesh to the list of scene's meshes
  39255. * @param newMesh defines the mesh to add
  39256. * @param recursive if all child meshes should also be added to the scene
  39257. */
  39258. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39259. /**
  39260. * Remove a mesh for the list of scene's meshes
  39261. * @param toRemove defines the mesh to remove
  39262. * @param recursive if all child meshes should also be removed from the scene
  39263. * @returns the index where the mesh was in the mesh list
  39264. */
  39265. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39266. /**
  39267. * Add a transform node to the list of scene's transform nodes
  39268. * @param newTransformNode defines the transform node to add
  39269. */
  39270. addTransformNode(newTransformNode: TransformNode): void;
  39271. /**
  39272. * Remove a transform node for the list of scene's transform nodes
  39273. * @param toRemove defines the transform node to remove
  39274. * @returns the index where the transform node was in the transform node list
  39275. */
  39276. removeTransformNode(toRemove: TransformNode): number;
  39277. /**
  39278. * Remove a skeleton for the list of scene's skeletons
  39279. * @param toRemove defines the skeleton to remove
  39280. * @returns the index where the skeleton was in the skeleton list
  39281. */
  39282. removeSkeleton(toRemove: Skeleton): number;
  39283. /**
  39284. * Remove a morph target for the list of scene's morph targets
  39285. * @param toRemove defines the morph target to remove
  39286. * @returns the index where the morph target was in the morph target list
  39287. */
  39288. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39289. /**
  39290. * Remove a light for the list of scene's lights
  39291. * @param toRemove defines the light to remove
  39292. * @returns the index where the light was in the light list
  39293. */
  39294. removeLight(toRemove: Light): number;
  39295. /**
  39296. * Remove a camera for the list of scene's cameras
  39297. * @param toRemove defines the camera to remove
  39298. * @returns the index where the camera was in the camera list
  39299. */
  39300. removeCamera(toRemove: Camera): number;
  39301. /**
  39302. * Remove a particle system for the list of scene's particle systems
  39303. * @param toRemove defines the particle system to remove
  39304. * @returns the index where the particle system was in the particle system list
  39305. */
  39306. removeParticleSystem(toRemove: IParticleSystem): number;
  39307. /**
  39308. * Remove a animation for the list of scene's animations
  39309. * @param toRemove defines the animation to remove
  39310. * @returns the index where the animation was in the animation list
  39311. */
  39312. removeAnimation(toRemove: Animation): number;
  39313. /**
  39314. * Will stop the animation of the given target
  39315. * @param target - the target
  39316. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39317. * @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)
  39318. */
  39319. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39320. /**
  39321. * Removes the given animation group from this scene.
  39322. * @param toRemove The animation group to remove
  39323. * @returns The index of the removed animation group
  39324. */
  39325. removeAnimationGroup(toRemove: AnimationGroup): number;
  39326. /**
  39327. * Removes the given multi-material from this scene.
  39328. * @param toRemove The multi-material to remove
  39329. * @returns The index of the removed multi-material
  39330. */
  39331. removeMultiMaterial(toRemove: MultiMaterial): number;
  39332. /**
  39333. * Removes the given material from this scene.
  39334. * @param toRemove The material to remove
  39335. * @returns The index of the removed material
  39336. */
  39337. removeMaterial(toRemove: Material): number;
  39338. /**
  39339. * Removes the given action manager from this scene.
  39340. * @param toRemove The action manager to remove
  39341. * @returns The index of the removed action manager
  39342. */
  39343. removeActionManager(toRemove: AbstractActionManager): number;
  39344. /**
  39345. * Removes the given texture from this scene.
  39346. * @param toRemove The texture to remove
  39347. * @returns The index of the removed texture
  39348. */
  39349. removeTexture(toRemove: BaseTexture): number;
  39350. /**
  39351. * Adds the given light to this scene
  39352. * @param newLight The light to add
  39353. */
  39354. addLight(newLight: Light): void;
  39355. /**
  39356. * Sorts the list list based on light priorities
  39357. */
  39358. sortLightsByPriority(): void;
  39359. /**
  39360. * Adds the given camera to this scene
  39361. * @param newCamera The camera to add
  39362. */
  39363. addCamera(newCamera: Camera): void;
  39364. /**
  39365. * Adds the given skeleton to this scene
  39366. * @param newSkeleton The skeleton to add
  39367. */
  39368. addSkeleton(newSkeleton: Skeleton): void;
  39369. /**
  39370. * Adds the given particle system to this scene
  39371. * @param newParticleSystem The particle system to add
  39372. */
  39373. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39374. /**
  39375. * Adds the given animation to this scene
  39376. * @param newAnimation The animation to add
  39377. */
  39378. addAnimation(newAnimation: Animation): void;
  39379. /**
  39380. * Adds the given animation group to this scene.
  39381. * @param newAnimationGroup The animation group to add
  39382. */
  39383. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39384. /**
  39385. * Adds the given multi-material to this scene
  39386. * @param newMultiMaterial The multi-material to add
  39387. */
  39388. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39389. /**
  39390. * Adds the given material to this scene
  39391. * @param newMaterial The material to add
  39392. */
  39393. addMaterial(newMaterial: Material): void;
  39394. /**
  39395. * Adds the given morph target to this scene
  39396. * @param newMorphTargetManager The morph target to add
  39397. */
  39398. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39399. /**
  39400. * Adds the given geometry to this scene
  39401. * @param newGeometry The geometry to add
  39402. */
  39403. addGeometry(newGeometry: Geometry): void;
  39404. /**
  39405. * Adds the given action manager to this scene
  39406. * @param newActionManager The action manager to add
  39407. */
  39408. addActionManager(newActionManager: AbstractActionManager): void;
  39409. /**
  39410. * Adds the given texture to this scene.
  39411. * @param newTexture The texture to add
  39412. */
  39413. addTexture(newTexture: BaseTexture): void;
  39414. /**
  39415. * Switch active camera
  39416. * @param newCamera defines the new active camera
  39417. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39418. */
  39419. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39420. /**
  39421. * sets the active camera of the scene using its ID
  39422. * @param id defines the camera's ID
  39423. * @return the new active camera or null if none found.
  39424. */
  39425. setActiveCameraByID(id: string): Nullable<Camera>;
  39426. /**
  39427. * sets the active camera of the scene using its name
  39428. * @param name defines the camera's name
  39429. * @returns the new active camera or null if none found.
  39430. */
  39431. setActiveCameraByName(name: string): Nullable<Camera>;
  39432. /**
  39433. * get an animation group using its name
  39434. * @param name defines the material's name
  39435. * @return the animation group or null if none found.
  39436. */
  39437. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39438. /**
  39439. * Get a material using its unique id
  39440. * @param uniqueId defines the material's unique id
  39441. * @return the material or null if none found.
  39442. */
  39443. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39444. /**
  39445. * get a material using its id
  39446. * @param id defines the material's ID
  39447. * @return the material or null if none found.
  39448. */
  39449. getMaterialByID(id: string): Nullable<Material>;
  39450. /**
  39451. * Gets a the last added material using a given id
  39452. * @param id defines the material's ID
  39453. * @return the last material with the given id or null if none found.
  39454. */
  39455. getLastMaterialByID(id: string): Nullable<Material>;
  39456. /**
  39457. * Gets a material using its name
  39458. * @param name defines the material's name
  39459. * @return the material or null if none found.
  39460. */
  39461. getMaterialByName(name: string): Nullable<Material>;
  39462. /**
  39463. * Get a texture using its unique id
  39464. * @param uniqueId defines the texture's unique id
  39465. * @return the texture or null if none found.
  39466. */
  39467. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39468. /**
  39469. * Gets a camera using its id
  39470. * @param id defines the id to look for
  39471. * @returns the camera or null if not found
  39472. */
  39473. getCameraByID(id: string): Nullable<Camera>;
  39474. /**
  39475. * Gets a camera using its unique id
  39476. * @param uniqueId defines the unique id to look for
  39477. * @returns the camera or null if not found
  39478. */
  39479. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39480. /**
  39481. * Gets a camera using its name
  39482. * @param name defines the camera's name
  39483. * @return the camera or null if none found.
  39484. */
  39485. getCameraByName(name: string): Nullable<Camera>;
  39486. /**
  39487. * Gets a bone using its id
  39488. * @param id defines the bone's id
  39489. * @return the bone or null if not found
  39490. */
  39491. getBoneByID(id: string): Nullable<Bone>;
  39492. /**
  39493. * Gets a bone using its id
  39494. * @param name defines the bone's name
  39495. * @return the bone or null if not found
  39496. */
  39497. getBoneByName(name: string): Nullable<Bone>;
  39498. /**
  39499. * Gets a light node using its name
  39500. * @param name defines the the light's name
  39501. * @return the light or null if none found.
  39502. */
  39503. getLightByName(name: string): Nullable<Light>;
  39504. /**
  39505. * Gets a light node using its id
  39506. * @param id defines the light's id
  39507. * @return the light or null if none found.
  39508. */
  39509. getLightByID(id: string): Nullable<Light>;
  39510. /**
  39511. * Gets a light node using its scene-generated unique ID
  39512. * @param uniqueId defines the light's unique id
  39513. * @return the light or null if none found.
  39514. */
  39515. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39516. /**
  39517. * Gets a particle system by id
  39518. * @param id defines the particle system id
  39519. * @return the corresponding system or null if none found
  39520. */
  39521. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39522. /**
  39523. * Gets a geometry using its ID
  39524. * @param id defines the geometry's id
  39525. * @return the geometry or null if none found.
  39526. */
  39527. getGeometryByID(id: string): Nullable<Geometry>;
  39528. private _getGeometryByUniqueID;
  39529. /**
  39530. * Add a new geometry to this scene
  39531. * @param geometry defines the geometry to be added to the scene.
  39532. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39533. * @return a boolean defining if the geometry was added or not
  39534. */
  39535. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39536. /**
  39537. * Removes an existing geometry
  39538. * @param geometry defines the geometry to be removed from the scene
  39539. * @return a boolean defining if the geometry was removed or not
  39540. */
  39541. removeGeometry(geometry: Geometry): boolean;
  39542. /**
  39543. * Gets the list of geometries attached to the scene
  39544. * @returns an array of Geometry
  39545. */
  39546. getGeometries(): Geometry[];
  39547. /**
  39548. * Gets the first added mesh found of a given ID
  39549. * @param id defines the id to search for
  39550. * @return the mesh found or null if not found at all
  39551. */
  39552. getMeshByID(id: string): Nullable<AbstractMesh>;
  39553. /**
  39554. * Gets a list of meshes using their id
  39555. * @param id defines the id to search for
  39556. * @returns a list of meshes
  39557. */
  39558. getMeshesByID(id: string): Array<AbstractMesh>;
  39559. /**
  39560. * Gets the first added transform node found of a given ID
  39561. * @param id defines the id to search for
  39562. * @return the found transform node or null if not found at all.
  39563. */
  39564. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39565. /**
  39566. * Gets a transform node with its auto-generated unique id
  39567. * @param uniqueId efines the unique id to search for
  39568. * @return the found transform node or null if not found at all.
  39569. */
  39570. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39571. /**
  39572. * Gets a list of transform nodes using their id
  39573. * @param id defines the id to search for
  39574. * @returns a list of transform nodes
  39575. */
  39576. getTransformNodesByID(id: string): Array<TransformNode>;
  39577. /**
  39578. * Gets a mesh with its auto-generated unique id
  39579. * @param uniqueId defines the unique id to search for
  39580. * @return the found mesh or null if not found at all.
  39581. */
  39582. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39583. /**
  39584. * Gets a the last added mesh using a given id
  39585. * @param id defines the id to search for
  39586. * @return the found mesh or null if not found at all.
  39587. */
  39588. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39589. /**
  39590. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39591. * @param id defines the id to search for
  39592. * @return the found node or null if not found at all
  39593. */
  39594. getLastEntryByID(id: string): Nullable<Node>;
  39595. /**
  39596. * Gets a node (Mesh, Camera, Light) using a given id
  39597. * @param id defines the id to search for
  39598. * @return the found node or null if not found at all
  39599. */
  39600. getNodeByID(id: string): Nullable<Node>;
  39601. /**
  39602. * Gets a node (Mesh, Camera, Light) using a given name
  39603. * @param name defines the name to search for
  39604. * @return the found node or null if not found at all.
  39605. */
  39606. getNodeByName(name: string): Nullable<Node>;
  39607. /**
  39608. * Gets a mesh using a given name
  39609. * @param name defines the name to search for
  39610. * @return the found mesh or null if not found at all.
  39611. */
  39612. getMeshByName(name: string): Nullable<AbstractMesh>;
  39613. /**
  39614. * Gets a transform node using a given name
  39615. * @param name defines the name to search for
  39616. * @return the found transform node or null if not found at all.
  39617. */
  39618. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39619. /**
  39620. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39621. * @param id defines the id to search for
  39622. * @return the found skeleton or null if not found at all.
  39623. */
  39624. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39625. /**
  39626. * Gets a skeleton using a given auto generated unique id
  39627. * @param uniqueId defines the unique id to search for
  39628. * @return the found skeleton or null if not found at all.
  39629. */
  39630. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39631. /**
  39632. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39633. * @param id defines the id to search for
  39634. * @return the found skeleton or null if not found at all.
  39635. */
  39636. getSkeletonById(id: string): Nullable<Skeleton>;
  39637. /**
  39638. * Gets a skeleton using a given name
  39639. * @param name defines the name to search for
  39640. * @return the found skeleton or null if not found at all.
  39641. */
  39642. getSkeletonByName(name: string): Nullable<Skeleton>;
  39643. /**
  39644. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39645. * @param id defines the id to search for
  39646. * @return the found morph target manager or null if not found at all.
  39647. */
  39648. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39649. /**
  39650. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39651. * @param id defines the id to search for
  39652. * @return the found morph target or null if not found at all.
  39653. */
  39654. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39655. /**
  39656. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39657. * @param name defines the name to search for
  39658. * @return the found morph target or null if not found at all.
  39659. */
  39660. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39661. /**
  39662. * Gets a boolean indicating if the given mesh is active
  39663. * @param mesh defines the mesh to look for
  39664. * @returns true if the mesh is in the active list
  39665. */
  39666. isActiveMesh(mesh: AbstractMesh): boolean;
  39667. /**
  39668. * Return a unique id as a string which can serve as an identifier for the scene
  39669. */
  39670. get uid(): string;
  39671. /**
  39672. * Add an externaly attached data from its key.
  39673. * This method call will fail and return false, if such key already exists.
  39674. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39675. * @param key the unique key that identifies the data
  39676. * @param data the data object to associate to the key for this Engine instance
  39677. * @return true if no such key were already present and the data was added successfully, false otherwise
  39678. */
  39679. addExternalData<T>(key: string, data: T): boolean;
  39680. /**
  39681. * Get an externaly attached data from its key
  39682. * @param key the unique key that identifies the data
  39683. * @return the associated data, if present (can be null), or undefined if not present
  39684. */
  39685. getExternalData<T>(key: string): Nullable<T>;
  39686. /**
  39687. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39688. * @param key the unique key that identifies the data
  39689. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39690. * @return the associated data, can be null if the factory returned null.
  39691. */
  39692. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39693. /**
  39694. * Remove an externaly attached data from the Engine instance
  39695. * @param key the unique key that identifies the data
  39696. * @return true if the data was successfully removed, false if it doesn't exist
  39697. */
  39698. removeExternalData(key: string): boolean;
  39699. private _evaluateSubMesh;
  39700. /**
  39701. * Clear the processed materials smart array preventing retention point in material dispose.
  39702. */
  39703. freeProcessedMaterials(): void;
  39704. private _preventFreeActiveMeshesAndRenderingGroups;
  39705. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39706. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39707. * when disposing several meshes in a row or a hierarchy of meshes.
  39708. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39709. */
  39710. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39711. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39712. /**
  39713. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39714. */
  39715. freeActiveMeshes(): void;
  39716. /**
  39717. * Clear the info related to rendering groups preventing retention points during dispose.
  39718. */
  39719. freeRenderingGroups(): void;
  39720. /** @hidden */
  39721. _isInIntermediateRendering(): boolean;
  39722. /**
  39723. * Lambda returning the list of potentially active meshes.
  39724. */
  39725. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39726. /**
  39727. * Lambda returning the list of potentially active sub meshes.
  39728. */
  39729. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39730. /**
  39731. * Lambda returning the list of potentially intersecting sub meshes.
  39732. */
  39733. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39734. /**
  39735. * Lambda returning the list of potentially colliding sub meshes.
  39736. */
  39737. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39738. private _activeMeshesFrozen;
  39739. private _skipEvaluateActiveMeshesCompletely;
  39740. /**
  39741. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39742. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39743. * @returns the current scene
  39744. */
  39745. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39746. /**
  39747. * Use this function to restart evaluating active meshes on every frame
  39748. * @returns the current scene
  39749. */
  39750. unfreezeActiveMeshes(): Scene;
  39751. private _evaluateActiveMeshes;
  39752. private _activeMesh;
  39753. /**
  39754. * Update the transform matrix to update from the current active camera
  39755. * @param force defines a boolean used to force the update even if cache is up to date
  39756. */
  39757. updateTransformMatrix(force?: boolean): void;
  39758. private _bindFrameBuffer;
  39759. /** @hidden */
  39760. _allowPostProcessClearColor: boolean;
  39761. /** @hidden */
  39762. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39763. private _processSubCameras;
  39764. private _checkIntersections;
  39765. /** @hidden */
  39766. _advancePhysicsEngineStep(step: number): void;
  39767. /**
  39768. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39769. */
  39770. getDeterministicFrameTime: () => number;
  39771. /** @hidden */
  39772. _animate(): void;
  39773. /** Execute all animations (for a frame) */
  39774. animate(): void;
  39775. /**
  39776. * Render the scene
  39777. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39778. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39779. */
  39780. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  39781. /**
  39782. * Freeze all materials
  39783. * A frozen material will not be updatable but should be faster to render
  39784. */
  39785. freezeMaterials(): void;
  39786. /**
  39787. * Unfreeze all materials
  39788. * A frozen material will not be updatable but should be faster to render
  39789. */
  39790. unfreezeMaterials(): void;
  39791. /**
  39792. * Releases all held ressources
  39793. */
  39794. dispose(): void;
  39795. /**
  39796. * Gets if the scene is already disposed
  39797. */
  39798. get isDisposed(): boolean;
  39799. /**
  39800. * Call this function to reduce memory footprint of the scene.
  39801. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  39802. */
  39803. clearCachedVertexData(): void;
  39804. /**
  39805. * This function will remove the local cached buffer data from texture.
  39806. * It will save memory but will prevent the texture from being rebuilt
  39807. */
  39808. cleanCachedTextureBuffer(): void;
  39809. /**
  39810. * Get the world extend vectors with an optional filter
  39811. *
  39812. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  39813. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  39814. */
  39815. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  39816. min: Vector3;
  39817. max: Vector3;
  39818. };
  39819. /**
  39820. * Creates a ray that can be used to pick in the scene
  39821. * @param x defines the x coordinate of the origin (on-screen)
  39822. * @param y defines the y coordinate of the origin (on-screen)
  39823. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39824. * @param camera defines the camera to use for the picking
  39825. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39826. * @returns a Ray
  39827. */
  39828. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  39829. /**
  39830. * Creates a ray that can be used to pick in the scene
  39831. * @param x defines the x coordinate of the origin (on-screen)
  39832. * @param y defines the y coordinate of the origin (on-screen)
  39833. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39834. * @param result defines the ray where to store the picking ray
  39835. * @param camera defines the camera to use for the picking
  39836. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39837. * @returns the current scene
  39838. */
  39839. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  39840. /**
  39841. * Creates a ray that can be used to pick in the scene
  39842. * @param x defines the x coordinate of the origin (on-screen)
  39843. * @param y defines the y coordinate of the origin (on-screen)
  39844. * @param camera defines the camera to use for the picking
  39845. * @returns a Ray
  39846. */
  39847. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  39848. /**
  39849. * Creates a ray that can be used to pick in the scene
  39850. * @param x defines the x coordinate of the origin (on-screen)
  39851. * @param y defines the y coordinate of the origin (on-screen)
  39852. * @param result defines the ray where to store the picking ray
  39853. * @param camera defines the camera to use for the picking
  39854. * @returns the current scene
  39855. */
  39856. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  39857. /** Launch a ray to try to pick a mesh in the scene
  39858. * @param x position on screen
  39859. * @param y position on screen
  39860. * @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
  39861. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39862. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39863. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39864. * @returns a PickingInfo
  39865. */
  39866. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39867. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  39868. * @param x position on screen
  39869. * @param y position on screen
  39870. * @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
  39871. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39872. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39873. * @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)
  39874. */
  39875. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  39876. /** Use the given ray to pick a mesh in the scene
  39877. * @param ray The ray to use to pick meshes
  39878. * @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
  39879. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39880. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39881. * @returns a PickingInfo
  39882. */
  39883. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39884. /**
  39885. * Launch a ray to try to pick a mesh in the scene
  39886. * @param x X position on screen
  39887. * @param y Y position on screen
  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 camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39890. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39891. * @returns an array of PickingInfo
  39892. */
  39893. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39894. /**
  39895. * Launch a ray to try to pick a mesh in the scene
  39896. * @param ray Ray to use
  39897. * @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
  39898. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39899. * @returns an array of PickingInfo
  39900. */
  39901. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39902. /**
  39903. * Force the value of meshUnderPointer
  39904. * @param mesh defines the mesh to use
  39905. */
  39906. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39907. /**
  39908. * Gets the mesh under the pointer
  39909. * @returns a Mesh or null if no mesh is under the pointer
  39910. */
  39911. getPointerOverMesh(): Nullable<AbstractMesh>;
  39912. /** @hidden */
  39913. _rebuildGeometries(): void;
  39914. /** @hidden */
  39915. _rebuildTextures(): void;
  39916. private _getByTags;
  39917. /**
  39918. * Get a list of meshes by tags
  39919. * @param tagsQuery defines the tags query to use
  39920. * @param forEach defines a predicate used to filter results
  39921. * @returns an array of Mesh
  39922. */
  39923. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  39924. /**
  39925. * Get a list of cameras by tags
  39926. * @param tagsQuery defines the tags query to use
  39927. * @param forEach defines a predicate used to filter results
  39928. * @returns an array of Camera
  39929. */
  39930. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  39931. /**
  39932. * Get a list of lights by tags
  39933. * @param tagsQuery defines the tags query to use
  39934. * @param forEach defines a predicate used to filter results
  39935. * @returns an array of Light
  39936. */
  39937. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  39938. /**
  39939. * Get a list of materials by tags
  39940. * @param tagsQuery defines the tags query to use
  39941. * @param forEach defines a predicate used to filter results
  39942. * @returns an array of Material
  39943. */
  39944. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  39945. /**
  39946. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39947. * This allowed control for front to back rendering or reversly depending of the special needs.
  39948. *
  39949. * @param renderingGroupId The rendering group id corresponding to its index
  39950. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39951. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39952. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39953. */
  39954. 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;
  39955. /**
  39956. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39957. *
  39958. * @param renderingGroupId The rendering group id corresponding to its index
  39959. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39960. * @param depth Automatically clears depth between groups if true and autoClear is true.
  39961. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  39962. */
  39963. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  39964. /**
  39965. * Gets the current auto clear configuration for one rendering group of the rendering
  39966. * manager.
  39967. * @param index the rendering group index to get the information for
  39968. * @returns The auto clear setup for the requested rendering group
  39969. */
  39970. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  39971. private _blockMaterialDirtyMechanism;
  39972. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  39973. get blockMaterialDirtyMechanism(): boolean;
  39974. set blockMaterialDirtyMechanism(value: boolean);
  39975. /**
  39976. * Will flag all materials as dirty to trigger new shader compilation
  39977. * @param flag defines the flag used to specify which material part must be marked as dirty
  39978. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  39979. */
  39980. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  39981. /** @hidden */
  39982. _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;
  39983. /** @hidden */
  39984. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39985. /** @hidden */
  39986. _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;
  39987. /** @hidden */
  39988. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  39989. /** @hidden */
  39990. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39991. /** @hidden */
  39992. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39993. }
  39994. }
  39995. declare module BABYLON {
  39996. /**
  39997. * Set of assets to keep when moving a scene into an asset container.
  39998. */
  39999. export class KeepAssets extends AbstractScene {
  40000. }
  40001. /**
  40002. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40003. */
  40004. export class InstantiatedEntries {
  40005. /**
  40006. * List of new root nodes (eg. nodes with no parent)
  40007. */
  40008. rootNodes: TransformNode[];
  40009. /**
  40010. * List of new skeletons
  40011. */
  40012. skeletons: Skeleton[];
  40013. /**
  40014. * List of new animation groups
  40015. */
  40016. animationGroups: AnimationGroup[];
  40017. }
  40018. /**
  40019. * Container with a set of assets that can be added or removed from a scene.
  40020. */
  40021. export class AssetContainer extends AbstractScene {
  40022. private _wasAddedToScene;
  40023. /**
  40024. * The scene the AssetContainer belongs to.
  40025. */
  40026. scene: Scene;
  40027. /**
  40028. * Instantiates an AssetContainer.
  40029. * @param scene The scene the AssetContainer belongs to.
  40030. */
  40031. constructor(scene: Scene);
  40032. /**
  40033. * Instantiate or clone all meshes and add the new ones to the scene.
  40034. * Skeletons and animation groups will all be cloned
  40035. * @param nameFunction defines an optional function used to get new names for clones
  40036. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40037. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40038. */
  40039. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40040. /**
  40041. * Adds all the assets from the container to the scene.
  40042. */
  40043. addAllToScene(): void;
  40044. /**
  40045. * Removes all the assets in the container from the scene
  40046. */
  40047. removeAllFromScene(): void;
  40048. /**
  40049. * Disposes all the assets in the container
  40050. */
  40051. dispose(): void;
  40052. private _moveAssets;
  40053. /**
  40054. * Removes all the assets contained in the scene and adds them to the container.
  40055. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40056. */
  40057. moveAllFromScene(keepAssets?: KeepAssets): void;
  40058. /**
  40059. * 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.
  40060. * @returns the root mesh
  40061. */
  40062. createRootMesh(): Mesh;
  40063. /**
  40064. * Merge animations (direct and animation groups) from this asset container into a scene
  40065. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40066. * @param animatables set of animatables to retarget to a node from the scene
  40067. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40068. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40069. */
  40070. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40071. }
  40072. }
  40073. declare module BABYLON {
  40074. /**
  40075. * Defines how the parser contract is defined.
  40076. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40077. */
  40078. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40079. /**
  40080. * Defines how the individual parser contract is defined.
  40081. * These parser can parse an individual asset
  40082. */
  40083. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40084. /**
  40085. * Base class of the scene acting as a container for the different elements composing a scene.
  40086. * This class is dynamically extended by the different components of the scene increasing
  40087. * flexibility and reducing coupling
  40088. */
  40089. export abstract class AbstractScene {
  40090. /**
  40091. * Stores the list of available parsers in the application.
  40092. */
  40093. private static _BabylonFileParsers;
  40094. /**
  40095. * Stores the list of available individual parsers in the application.
  40096. */
  40097. private static _IndividualBabylonFileParsers;
  40098. /**
  40099. * Adds a parser in the list of available ones
  40100. * @param name Defines the name of the parser
  40101. * @param parser Defines the parser to add
  40102. */
  40103. static AddParser(name: string, parser: BabylonFileParser): void;
  40104. /**
  40105. * Gets a general parser from the list of avaialble ones
  40106. * @param name Defines the name of the parser
  40107. * @returns the requested parser or null
  40108. */
  40109. static GetParser(name: string): Nullable<BabylonFileParser>;
  40110. /**
  40111. * Adds n individual parser in the list of available ones
  40112. * @param name Defines the name of the parser
  40113. * @param parser Defines the parser to add
  40114. */
  40115. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40116. /**
  40117. * Gets an individual parser from the list of avaialble ones
  40118. * @param name Defines the name of the parser
  40119. * @returns the requested parser or null
  40120. */
  40121. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40122. /**
  40123. * Parser json data and populate both a scene and its associated container object
  40124. * @param jsonData Defines the data to parse
  40125. * @param scene Defines the scene to parse the data for
  40126. * @param container Defines the container attached to the parsing sequence
  40127. * @param rootUrl Defines the root url of the data
  40128. */
  40129. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40130. /**
  40131. * Gets the list of root nodes (ie. nodes with no parent)
  40132. */
  40133. rootNodes: Node[];
  40134. /** All of the cameras added to this scene
  40135. * @see http://doc.babylonjs.com/babylon101/cameras
  40136. */
  40137. cameras: Camera[];
  40138. /**
  40139. * All of the lights added to this scene
  40140. * @see http://doc.babylonjs.com/babylon101/lights
  40141. */
  40142. lights: Light[];
  40143. /**
  40144. * All of the (abstract) meshes added to this scene
  40145. */
  40146. meshes: AbstractMesh[];
  40147. /**
  40148. * The list of skeletons added to the scene
  40149. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40150. */
  40151. skeletons: Skeleton[];
  40152. /**
  40153. * All of the particle systems added to this scene
  40154. * @see http://doc.babylonjs.com/babylon101/particles
  40155. */
  40156. particleSystems: IParticleSystem[];
  40157. /**
  40158. * Gets a list of Animations associated with the scene
  40159. */
  40160. animations: Animation[];
  40161. /**
  40162. * All of the animation groups added to this scene
  40163. * @see http://doc.babylonjs.com/how_to/group
  40164. */
  40165. animationGroups: AnimationGroup[];
  40166. /**
  40167. * All of the multi-materials added to this scene
  40168. * @see http://doc.babylonjs.com/how_to/multi_materials
  40169. */
  40170. multiMaterials: MultiMaterial[];
  40171. /**
  40172. * All of the materials added to this scene
  40173. * In the context of a Scene, it is not supposed to be modified manually.
  40174. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40175. * Note also that the order of the Material within the array is not significant and might change.
  40176. * @see http://doc.babylonjs.com/babylon101/materials
  40177. */
  40178. materials: Material[];
  40179. /**
  40180. * The list of morph target managers added to the scene
  40181. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40182. */
  40183. morphTargetManagers: MorphTargetManager[];
  40184. /**
  40185. * The list of geometries used in the scene.
  40186. */
  40187. geometries: Geometry[];
  40188. /**
  40189. * All of the tranform nodes added to this scene
  40190. * In the context of a Scene, it is not supposed to be modified manually.
  40191. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40192. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40193. * @see http://doc.babylonjs.com/how_to/transformnode
  40194. */
  40195. transformNodes: TransformNode[];
  40196. /**
  40197. * ActionManagers available on the scene.
  40198. */
  40199. actionManagers: AbstractActionManager[];
  40200. /**
  40201. * Textures to keep.
  40202. */
  40203. textures: BaseTexture[];
  40204. /**
  40205. * Environment texture for the scene
  40206. */
  40207. environmentTexture: Nullable<BaseTexture>;
  40208. /**
  40209. * @returns all meshes, lights, cameras, transformNodes and bones
  40210. */
  40211. getNodes(): Array<Node>;
  40212. }
  40213. }
  40214. declare module BABYLON {
  40215. /**
  40216. * Interface used to define options for Sound class
  40217. */
  40218. export interface ISoundOptions {
  40219. /**
  40220. * Does the sound autoplay once loaded.
  40221. */
  40222. autoplay?: boolean;
  40223. /**
  40224. * Does the sound loop after it finishes playing once.
  40225. */
  40226. loop?: boolean;
  40227. /**
  40228. * Sound's volume
  40229. */
  40230. volume?: number;
  40231. /**
  40232. * Is it a spatial sound?
  40233. */
  40234. spatialSound?: boolean;
  40235. /**
  40236. * Maximum distance to hear that sound
  40237. */
  40238. maxDistance?: number;
  40239. /**
  40240. * Uses user defined attenuation function
  40241. */
  40242. useCustomAttenuation?: boolean;
  40243. /**
  40244. * Define the roll off factor of spatial sounds.
  40245. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40246. */
  40247. rolloffFactor?: number;
  40248. /**
  40249. * Define the reference distance the sound should be heard perfectly.
  40250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40251. */
  40252. refDistance?: number;
  40253. /**
  40254. * Define the distance attenuation model the sound will follow.
  40255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40256. */
  40257. distanceModel?: string;
  40258. /**
  40259. * Defines the playback speed (1 by default)
  40260. */
  40261. playbackRate?: number;
  40262. /**
  40263. * Defines if the sound is from a streaming source
  40264. */
  40265. streaming?: boolean;
  40266. /**
  40267. * Defines an optional length (in seconds) inside the sound file
  40268. */
  40269. length?: number;
  40270. /**
  40271. * Defines an optional offset (in seconds) inside the sound file
  40272. */
  40273. offset?: number;
  40274. /**
  40275. * If true, URLs will not be required to state the audio file codec to use.
  40276. */
  40277. skipCodecCheck?: boolean;
  40278. }
  40279. /**
  40280. * Defines a sound that can be played in the application.
  40281. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40283. */
  40284. export class Sound {
  40285. /**
  40286. * The name of the sound in the scene.
  40287. */
  40288. name: string;
  40289. /**
  40290. * Does the sound autoplay once loaded.
  40291. */
  40292. autoplay: boolean;
  40293. /**
  40294. * Does the sound loop after it finishes playing once.
  40295. */
  40296. loop: boolean;
  40297. /**
  40298. * Does the sound use a custom attenuation curve to simulate the falloff
  40299. * happening when the source gets further away from the camera.
  40300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40301. */
  40302. useCustomAttenuation: boolean;
  40303. /**
  40304. * The sound track id this sound belongs to.
  40305. */
  40306. soundTrackId: number;
  40307. /**
  40308. * Is this sound currently played.
  40309. */
  40310. isPlaying: boolean;
  40311. /**
  40312. * Is this sound currently paused.
  40313. */
  40314. isPaused: boolean;
  40315. /**
  40316. * Does this sound enables spatial sound.
  40317. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40318. */
  40319. spatialSound: boolean;
  40320. /**
  40321. * Define the reference distance the sound should be heard perfectly.
  40322. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40323. */
  40324. refDistance: number;
  40325. /**
  40326. * Define the roll off factor of spatial sounds.
  40327. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40328. */
  40329. rolloffFactor: number;
  40330. /**
  40331. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40332. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40333. */
  40334. maxDistance: number;
  40335. /**
  40336. * Define the distance attenuation model the sound will follow.
  40337. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40338. */
  40339. distanceModel: string;
  40340. /**
  40341. * @hidden
  40342. * Back Compat
  40343. **/
  40344. onended: () => any;
  40345. /**
  40346. * Gets or sets an object used to store user defined information for the sound.
  40347. */
  40348. metadata: any;
  40349. /**
  40350. * Observable event when the current playing sound finishes.
  40351. */
  40352. onEndedObservable: Observable<Sound>;
  40353. private _panningModel;
  40354. private _playbackRate;
  40355. private _streaming;
  40356. private _startTime;
  40357. private _startOffset;
  40358. private _position;
  40359. /** @hidden */
  40360. _positionInEmitterSpace: boolean;
  40361. private _localDirection;
  40362. private _volume;
  40363. private _isReadyToPlay;
  40364. private _isDirectional;
  40365. private _readyToPlayCallback;
  40366. private _audioBuffer;
  40367. private _soundSource;
  40368. private _streamingSource;
  40369. private _soundPanner;
  40370. private _soundGain;
  40371. private _inputAudioNode;
  40372. private _outputAudioNode;
  40373. private _coneInnerAngle;
  40374. private _coneOuterAngle;
  40375. private _coneOuterGain;
  40376. private _scene;
  40377. private _connectedTransformNode;
  40378. private _customAttenuationFunction;
  40379. private _registerFunc;
  40380. private _isOutputConnected;
  40381. private _htmlAudioElement;
  40382. private _urlType;
  40383. private _length?;
  40384. private _offset?;
  40385. /** @hidden */
  40386. static _SceneComponentInitialization: (scene: Scene) => void;
  40387. /**
  40388. * Create a sound and attach it to a scene
  40389. * @param name Name of your sound
  40390. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40391. * @param scene defines the scene the sound belongs to
  40392. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40393. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40394. */
  40395. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40396. /**
  40397. * Release the sound and its associated resources
  40398. */
  40399. dispose(): void;
  40400. /**
  40401. * Gets if the sounds is ready to be played or not.
  40402. * @returns true if ready, otherwise false
  40403. */
  40404. isReady(): boolean;
  40405. private _soundLoaded;
  40406. /**
  40407. * Sets the data of the sound from an audiobuffer
  40408. * @param audioBuffer The audioBuffer containing the data
  40409. */
  40410. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40411. /**
  40412. * Updates the current sounds options such as maxdistance, loop...
  40413. * @param options A JSON object containing values named as the object properties
  40414. */
  40415. updateOptions(options: ISoundOptions): void;
  40416. private _createSpatialParameters;
  40417. private _updateSpatialParameters;
  40418. /**
  40419. * Switch the panning model to HRTF:
  40420. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40422. */
  40423. switchPanningModelToHRTF(): void;
  40424. /**
  40425. * Switch the panning model to Equal Power:
  40426. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40427. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40428. */
  40429. switchPanningModelToEqualPower(): void;
  40430. private _switchPanningModel;
  40431. /**
  40432. * Connect this sound to a sound track audio node like gain...
  40433. * @param soundTrackAudioNode the sound track audio node to connect to
  40434. */
  40435. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40436. /**
  40437. * Transform this sound into a directional source
  40438. * @param coneInnerAngle Size of the inner cone in degree
  40439. * @param coneOuterAngle Size of the outer cone in degree
  40440. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40441. */
  40442. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40443. /**
  40444. * Gets or sets the inner angle for the directional cone.
  40445. */
  40446. get directionalConeInnerAngle(): number;
  40447. /**
  40448. * Gets or sets the inner angle for the directional cone.
  40449. */
  40450. set directionalConeInnerAngle(value: number);
  40451. /**
  40452. * Gets or sets the outer angle for the directional cone.
  40453. */
  40454. get directionalConeOuterAngle(): number;
  40455. /**
  40456. * Gets or sets the outer angle for the directional cone.
  40457. */
  40458. set directionalConeOuterAngle(value: number);
  40459. /**
  40460. * Sets the position of the emitter if spatial sound is enabled
  40461. * @param newPosition Defines the new posisiton
  40462. */
  40463. setPosition(newPosition: Vector3): void;
  40464. /**
  40465. * Sets the local direction of the emitter if spatial sound is enabled
  40466. * @param newLocalDirection Defines the new local direction
  40467. */
  40468. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40469. private _updateDirection;
  40470. /** @hidden */
  40471. updateDistanceFromListener(): void;
  40472. /**
  40473. * Sets a new custom attenuation function for the sound.
  40474. * @param callback Defines the function used for the attenuation
  40475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40476. */
  40477. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40478. /**
  40479. * Play the sound
  40480. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40481. * @param offset (optional) Start the sound at a specific time in seconds
  40482. * @param length (optional) Sound duration (in seconds)
  40483. */
  40484. play(time?: number, offset?: number, length?: number): void;
  40485. private _onended;
  40486. /**
  40487. * Stop the sound
  40488. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40489. */
  40490. stop(time?: number): void;
  40491. /**
  40492. * Put the sound in pause
  40493. */
  40494. pause(): void;
  40495. /**
  40496. * Sets a dedicated volume for this sounds
  40497. * @param newVolume Define the new volume of the sound
  40498. * @param time Define time for gradual change to new volume
  40499. */
  40500. setVolume(newVolume: number, time?: number): void;
  40501. /**
  40502. * Set the sound play back rate
  40503. * @param newPlaybackRate Define the playback rate the sound should be played at
  40504. */
  40505. setPlaybackRate(newPlaybackRate: number): void;
  40506. /**
  40507. * Gets the volume of the sound.
  40508. * @returns the volume of the sound
  40509. */
  40510. getVolume(): number;
  40511. /**
  40512. * Attach the sound to a dedicated mesh
  40513. * @param transformNode The transform node to connect the sound with
  40514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40515. */
  40516. attachToMesh(transformNode: TransformNode): void;
  40517. /**
  40518. * Detach the sound from the previously attached mesh
  40519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40520. */
  40521. detachFromMesh(): void;
  40522. private _onRegisterAfterWorldMatrixUpdate;
  40523. /**
  40524. * Clone the current sound in the scene.
  40525. * @returns the new sound clone
  40526. */
  40527. clone(): Nullable<Sound>;
  40528. /**
  40529. * Gets the current underlying audio buffer containing the data
  40530. * @returns the audio buffer
  40531. */
  40532. getAudioBuffer(): Nullable<AudioBuffer>;
  40533. /**
  40534. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40535. * @returns the source node
  40536. */
  40537. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40538. /**
  40539. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40540. * @returns the gain node
  40541. */
  40542. getSoundGain(): Nullable<GainNode>;
  40543. /**
  40544. * Serializes the Sound in a JSON representation
  40545. * @returns the JSON representation of the sound
  40546. */
  40547. serialize(): any;
  40548. /**
  40549. * Parse a JSON representation of a sound to innstantiate in a given scene
  40550. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40551. * @param scene Define the scene the new parsed sound should be created in
  40552. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40553. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40554. * @returns the newly parsed sound
  40555. */
  40556. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40557. }
  40558. }
  40559. declare module BABYLON {
  40560. /**
  40561. * This defines an action helpful to play a defined sound on a triggered action.
  40562. */
  40563. export class PlaySoundAction extends Action {
  40564. private _sound;
  40565. /**
  40566. * Instantiate the action
  40567. * @param triggerOptions defines the trigger options
  40568. * @param sound defines the sound to play
  40569. * @param condition defines the trigger related conditions
  40570. */
  40571. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40572. /** @hidden */
  40573. _prepare(): void;
  40574. /**
  40575. * Execute the action and play the sound.
  40576. */
  40577. execute(): void;
  40578. /**
  40579. * Serializes the actions and its related information.
  40580. * @param parent defines the object to serialize in
  40581. * @returns the serialized object
  40582. */
  40583. serialize(parent: any): any;
  40584. }
  40585. /**
  40586. * This defines an action helpful to stop a defined sound on a triggered action.
  40587. */
  40588. export class StopSoundAction extends Action {
  40589. private _sound;
  40590. /**
  40591. * Instantiate the action
  40592. * @param triggerOptions defines the trigger options
  40593. * @param sound defines the sound to stop
  40594. * @param condition defines the trigger related conditions
  40595. */
  40596. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40597. /** @hidden */
  40598. _prepare(): void;
  40599. /**
  40600. * Execute the action and stop the sound.
  40601. */
  40602. execute(): void;
  40603. /**
  40604. * Serializes the actions and its related information.
  40605. * @param parent defines the object to serialize in
  40606. * @returns the serialized object
  40607. */
  40608. serialize(parent: any): any;
  40609. }
  40610. }
  40611. declare module BABYLON {
  40612. /**
  40613. * This defines an action responsible to change the value of a property
  40614. * by interpolating between its current value and the newly set one once triggered.
  40615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40616. */
  40617. export class InterpolateValueAction extends Action {
  40618. /**
  40619. * Defines the path of the property where the value should be interpolated
  40620. */
  40621. propertyPath: string;
  40622. /**
  40623. * Defines the target value at the end of the interpolation.
  40624. */
  40625. value: any;
  40626. /**
  40627. * Defines the time it will take for the property to interpolate to the value.
  40628. */
  40629. duration: number;
  40630. /**
  40631. * Defines if the other scene animations should be stopped when the action has been triggered
  40632. */
  40633. stopOtherAnimations?: boolean;
  40634. /**
  40635. * Defines a callback raised once the interpolation animation has been done.
  40636. */
  40637. onInterpolationDone?: () => void;
  40638. /**
  40639. * Observable triggered once the interpolation animation has been done.
  40640. */
  40641. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40642. private _target;
  40643. private _effectiveTarget;
  40644. private _property;
  40645. /**
  40646. * Instantiate the action
  40647. * @param triggerOptions defines the trigger options
  40648. * @param target defines the object containing the value to interpolate
  40649. * @param propertyPath defines the path to the property in the target object
  40650. * @param value defines the target value at the end of the interpolation
  40651. * @param duration deines the time it will take for the property to interpolate to the value.
  40652. * @param condition defines the trigger related conditions
  40653. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40654. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40655. */
  40656. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40657. /** @hidden */
  40658. _prepare(): void;
  40659. /**
  40660. * Execute the action starts the value interpolation.
  40661. */
  40662. execute(): void;
  40663. /**
  40664. * Serializes the actions and its related information.
  40665. * @param parent defines the object to serialize in
  40666. * @returns the serialized object
  40667. */
  40668. serialize(parent: any): any;
  40669. }
  40670. }
  40671. declare module BABYLON {
  40672. /**
  40673. * Options allowed during the creation of a sound track.
  40674. */
  40675. export interface ISoundTrackOptions {
  40676. /**
  40677. * The volume the sound track should take during creation
  40678. */
  40679. volume?: number;
  40680. /**
  40681. * Define if the sound track is the main sound track of the scene
  40682. */
  40683. mainTrack?: boolean;
  40684. }
  40685. /**
  40686. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40687. * It will be also used in a future release to apply effects on a specific track.
  40688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40689. */
  40690. export class SoundTrack {
  40691. /**
  40692. * The unique identifier of the sound track in the scene.
  40693. */
  40694. id: number;
  40695. /**
  40696. * The list of sounds included in the sound track.
  40697. */
  40698. soundCollection: Array<Sound>;
  40699. private _outputAudioNode;
  40700. private _scene;
  40701. private _connectedAnalyser;
  40702. private _options;
  40703. private _isInitialized;
  40704. /**
  40705. * Creates a new sound track.
  40706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40707. * @param scene Define the scene the sound track belongs to
  40708. * @param options
  40709. */
  40710. constructor(scene: Scene, options?: ISoundTrackOptions);
  40711. private _initializeSoundTrackAudioGraph;
  40712. /**
  40713. * Release the sound track and its associated resources
  40714. */
  40715. dispose(): void;
  40716. /**
  40717. * Adds a sound to this sound track
  40718. * @param sound define the cound to add
  40719. * @ignoreNaming
  40720. */
  40721. AddSound(sound: Sound): void;
  40722. /**
  40723. * Removes a sound to this sound track
  40724. * @param sound define the cound to remove
  40725. * @ignoreNaming
  40726. */
  40727. RemoveSound(sound: Sound): void;
  40728. /**
  40729. * Set a global volume for the full sound track.
  40730. * @param newVolume Define the new volume of the sound track
  40731. */
  40732. setVolume(newVolume: number): void;
  40733. /**
  40734. * Switch the panning model to HRTF:
  40735. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40737. */
  40738. switchPanningModelToHRTF(): void;
  40739. /**
  40740. * Switch the panning model to Equal Power:
  40741. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40743. */
  40744. switchPanningModelToEqualPower(): void;
  40745. /**
  40746. * Connect the sound track to an audio analyser allowing some amazing
  40747. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40749. * @param analyser The analyser to connect to the engine
  40750. */
  40751. connectToAnalyser(analyser: Analyser): void;
  40752. }
  40753. }
  40754. declare module BABYLON {
  40755. interface AbstractScene {
  40756. /**
  40757. * The list of sounds used in the scene.
  40758. */
  40759. sounds: Nullable<Array<Sound>>;
  40760. }
  40761. interface Scene {
  40762. /**
  40763. * @hidden
  40764. * Backing field
  40765. */
  40766. _mainSoundTrack: SoundTrack;
  40767. /**
  40768. * The main sound track played by the scene.
  40769. * It cotains your primary collection of sounds.
  40770. */
  40771. mainSoundTrack: SoundTrack;
  40772. /**
  40773. * The list of sound tracks added to the scene
  40774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40775. */
  40776. soundTracks: Nullable<Array<SoundTrack>>;
  40777. /**
  40778. * Gets a sound using a given name
  40779. * @param name defines the name to search for
  40780. * @return the found sound or null if not found at all.
  40781. */
  40782. getSoundByName(name: string): Nullable<Sound>;
  40783. /**
  40784. * Gets or sets if audio support is enabled
  40785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40786. */
  40787. audioEnabled: boolean;
  40788. /**
  40789. * Gets or sets if audio will be output to headphones
  40790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40791. */
  40792. headphone: boolean;
  40793. /**
  40794. * Gets or sets custom audio listener position provider
  40795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40796. */
  40797. audioListenerPositionProvider: Nullable<() => Vector3>;
  40798. /**
  40799. * Gets or sets a refresh rate when using 3D audio positioning
  40800. */
  40801. audioPositioningRefreshRate: number;
  40802. }
  40803. /**
  40804. * Defines the sound scene component responsible to manage any sounds
  40805. * in a given scene.
  40806. */
  40807. export class AudioSceneComponent implements ISceneSerializableComponent {
  40808. /**
  40809. * The component name helpfull to identify the component in the list of scene components.
  40810. */
  40811. readonly name: string;
  40812. /**
  40813. * The scene the component belongs to.
  40814. */
  40815. scene: Scene;
  40816. private _audioEnabled;
  40817. /**
  40818. * Gets whether audio is enabled or not.
  40819. * Please use related enable/disable method to switch state.
  40820. */
  40821. get audioEnabled(): boolean;
  40822. private _headphone;
  40823. /**
  40824. * Gets whether audio is outputing to headphone or not.
  40825. * Please use the according Switch methods to change output.
  40826. */
  40827. get headphone(): boolean;
  40828. /**
  40829. * Gets or sets a refresh rate when using 3D audio positioning
  40830. */
  40831. audioPositioningRefreshRate: number;
  40832. private _audioListenerPositionProvider;
  40833. /**
  40834. * Gets the current audio listener position provider
  40835. */
  40836. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  40837. /**
  40838. * Sets a custom listener position for all sounds in the scene
  40839. * By default, this is the position of the first active camera
  40840. */
  40841. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  40842. /**
  40843. * Creates a new instance of the component for the given scene
  40844. * @param scene Defines the scene to register the component in
  40845. */
  40846. constructor(scene: Scene);
  40847. /**
  40848. * Registers the component in a given scene
  40849. */
  40850. register(): void;
  40851. /**
  40852. * Rebuilds the elements related to this component in case of
  40853. * context lost for instance.
  40854. */
  40855. rebuild(): void;
  40856. /**
  40857. * Serializes the component data to the specified json object
  40858. * @param serializationObject The object to serialize to
  40859. */
  40860. serialize(serializationObject: any): void;
  40861. /**
  40862. * Adds all the elements from the container to the scene
  40863. * @param container the container holding the elements
  40864. */
  40865. addFromContainer(container: AbstractScene): void;
  40866. /**
  40867. * Removes all the elements in the container from the scene
  40868. * @param container contains the elements to remove
  40869. * @param dispose if the removed element should be disposed (default: false)
  40870. */
  40871. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  40872. /**
  40873. * Disposes the component and the associated ressources.
  40874. */
  40875. dispose(): void;
  40876. /**
  40877. * Disables audio in the associated scene.
  40878. */
  40879. disableAudio(): void;
  40880. /**
  40881. * Enables audio in the associated scene.
  40882. */
  40883. enableAudio(): void;
  40884. /**
  40885. * Switch audio to headphone output.
  40886. */
  40887. switchAudioModeForHeadphones(): void;
  40888. /**
  40889. * Switch audio to normal speakers.
  40890. */
  40891. switchAudioModeForNormalSpeakers(): void;
  40892. private _cachedCameraDirection;
  40893. private _cachedCameraPosition;
  40894. private _lastCheck;
  40895. private _afterRender;
  40896. }
  40897. }
  40898. declare module BABYLON {
  40899. /**
  40900. * Wraps one or more Sound objects and selects one with random weight for playback.
  40901. */
  40902. export class WeightedSound {
  40903. /** When true a Sound will be selected and played when the current playing Sound completes. */
  40904. loop: boolean;
  40905. private _coneInnerAngle;
  40906. private _coneOuterAngle;
  40907. private _volume;
  40908. /** A Sound is currently playing. */
  40909. isPlaying: boolean;
  40910. /** A Sound is currently paused. */
  40911. isPaused: boolean;
  40912. private _sounds;
  40913. private _weights;
  40914. private _currentIndex?;
  40915. /**
  40916. * Creates a new WeightedSound from the list of sounds given.
  40917. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  40918. * @param sounds Array of Sounds that will be selected from.
  40919. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  40920. */
  40921. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  40922. /**
  40923. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  40924. */
  40925. get directionalConeInnerAngle(): number;
  40926. /**
  40927. * The size of cone in degress for a directional sound in which there will be no attenuation.
  40928. */
  40929. set directionalConeInnerAngle(value: number);
  40930. /**
  40931. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40932. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40933. */
  40934. get directionalConeOuterAngle(): number;
  40935. /**
  40936. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40937. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40938. */
  40939. set directionalConeOuterAngle(value: number);
  40940. /**
  40941. * Playback volume.
  40942. */
  40943. get volume(): number;
  40944. /**
  40945. * Playback volume.
  40946. */
  40947. set volume(value: number);
  40948. private _onended;
  40949. /**
  40950. * Suspend playback
  40951. */
  40952. pause(): void;
  40953. /**
  40954. * Stop playback
  40955. */
  40956. stop(): void;
  40957. /**
  40958. * Start playback.
  40959. * @param startOffset Position the clip head at a specific time in seconds.
  40960. */
  40961. play(startOffset?: number): void;
  40962. }
  40963. }
  40964. declare module BABYLON {
  40965. /**
  40966. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40967. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40968. */
  40969. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40970. /**
  40971. * Gets the name of the behavior.
  40972. */
  40973. get name(): string;
  40974. /**
  40975. * The easing function used by animations
  40976. */
  40977. static EasingFunction: BackEase;
  40978. /**
  40979. * The easing mode used by animations
  40980. */
  40981. static EasingMode: number;
  40982. /**
  40983. * The duration of the animation, in milliseconds
  40984. */
  40985. transitionDuration: number;
  40986. /**
  40987. * Length of the distance animated by the transition when lower radius is reached
  40988. */
  40989. lowerRadiusTransitionRange: number;
  40990. /**
  40991. * Length of the distance animated by the transition when upper radius is reached
  40992. */
  40993. upperRadiusTransitionRange: number;
  40994. private _autoTransitionRange;
  40995. /**
  40996. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40997. */
  40998. get autoTransitionRange(): boolean;
  40999. /**
  41000. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41001. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41002. */
  41003. set autoTransitionRange(value: boolean);
  41004. private _attachedCamera;
  41005. private _onAfterCheckInputsObserver;
  41006. private _onMeshTargetChangedObserver;
  41007. /**
  41008. * Initializes the behavior.
  41009. */
  41010. init(): void;
  41011. /**
  41012. * Attaches the behavior to its arc rotate camera.
  41013. * @param camera Defines the camera to attach the behavior to
  41014. */
  41015. attach(camera: ArcRotateCamera): void;
  41016. /**
  41017. * Detaches the behavior from its current arc rotate camera.
  41018. */
  41019. detach(): void;
  41020. private _radiusIsAnimating;
  41021. private _radiusBounceTransition;
  41022. private _animatables;
  41023. private _cachedWheelPrecision;
  41024. /**
  41025. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41026. * @param radiusLimit The limit to check against.
  41027. * @return Bool to indicate if at limit.
  41028. */
  41029. private _isRadiusAtLimit;
  41030. /**
  41031. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41032. * @param radiusDelta The delta by which to animate to. Can be negative.
  41033. */
  41034. private _applyBoundRadiusAnimation;
  41035. /**
  41036. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41037. */
  41038. protected _clearAnimationLocks(): void;
  41039. /**
  41040. * Stops and removes all animations that have been applied to the camera
  41041. */
  41042. stopAllAnimations(): void;
  41043. }
  41044. }
  41045. declare module BABYLON {
  41046. /**
  41047. * 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.
  41048. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41049. */
  41050. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41051. /**
  41052. * Gets the name of the behavior.
  41053. */
  41054. get name(): string;
  41055. private _mode;
  41056. private _radiusScale;
  41057. private _positionScale;
  41058. private _defaultElevation;
  41059. private _elevationReturnTime;
  41060. private _elevationReturnWaitTime;
  41061. private _zoomStopsAnimation;
  41062. private _framingTime;
  41063. /**
  41064. * The easing function used by animations
  41065. */
  41066. static EasingFunction: ExponentialEase;
  41067. /**
  41068. * The easing mode used by animations
  41069. */
  41070. static EasingMode: number;
  41071. /**
  41072. * Sets the current mode used by the behavior
  41073. */
  41074. set mode(mode: number);
  41075. /**
  41076. * Gets current mode used by the behavior.
  41077. */
  41078. get mode(): number;
  41079. /**
  41080. * Sets the scale applied to the radius (1 by default)
  41081. */
  41082. set radiusScale(radius: number);
  41083. /**
  41084. * Gets the scale applied to the radius
  41085. */
  41086. get radiusScale(): number;
  41087. /**
  41088. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41089. */
  41090. set positionScale(scale: number);
  41091. /**
  41092. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41093. */
  41094. get positionScale(): number;
  41095. /**
  41096. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41097. * behaviour is triggered, in radians.
  41098. */
  41099. set defaultElevation(elevation: number);
  41100. /**
  41101. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41102. * behaviour is triggered, in radians.
  41103. */
  41104. get defaultElevation(): number;
  41105. /**
  41106. * Sets the time (in milliseconds) taken to return to the default beta position.
  41107. * Negative value indicates camera should not return to default.
  41108. */
  41109. set elevationReturnTime(speed: number);
  41110. /**
  41111. * Gets the time (in milliseconds) taken to return to the default beta position.
  41112. * Negative value indicates camera should not return to default.
  41113. */
  41114. get elevationReturnTime(): number;
  41115. /**
  41116. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41117. */
  41118. set elevationReturnWaitTime(time: number);
  41119. /**
  41120. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41121. */
  41122. get elevationReturnWaitTime(): number;
  41123. /**
  41124. * Sets the flag that indicates if user zooming should stop animation.
  41125. */
  41126. set zoomStopsAnimation(flag: boolean);
  41127. /**
  41128. * Gets the flag that indicates if user zooming should stop animation.
  41129. */
  41130. get zoomStopsAnimation(): boolean;
  41131. /**
  41132. * Sets the transition time when framing the mesh, in milliseconds
  41133. */
  41134. set framingTime(time: number);
  41135. /**
  41136. * Gets the transition time when framing the mesh, in milliseconds
  41137. */
  41138. get framingTime(): number;
  41139. /**
  41140. * Define if the behavior should automatically change the configured
  41141. * camera limits and sensibilities.
  41142. */
  41143. autoCorrectCameraLimitsAndSensibility: boolean;
  41144. private _onPrePointerObservableObserver;
  41145. private _onAfterCheckInputsObserver;
  41146. private _onMeshTargetChangedObserver;
  41147. private _attachedCamera;
  41148. private _isPointerDown;
  41149. private _lastInteractionTime;
  41150. /**
  41151. * Initializes the behavior.
  41152. */
  41153. init(): void;
  41154. /**
  41155. * Attaches the behavior to its arc rotate camera.
  41156. * @param camera Defines the camera to attach the behavior to
  41157. */
  41158. attach(camera: ArcRotateCamera): void;
  41159. /**
  41160. * Detaches the behavior from its current arc rotate camera.
  41161. */
  41162. detach(): void;
  41163. private _animatables;
  41164. private _betaIsAnimating;
  41165. private _betaTransition;
  41166. private _radiusTransition;
  41167. private _vectorTransition;
  41168. /**
  41169. * Targets the given mesh and updates zoom level accordingly.
  41170. * @param mesh The mesh to target.
  41171. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41172. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41173. */
  41174. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41175. /**
  41176. * Targets the given mesh with its children and updates zoom level accordingly.
  41177. * @param mesh The mesh to target.
  41178. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41179. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41180. */
  41181. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41182. /**
  41183. * Targets the given meshes with their children and updates zoom level accordingly.
  41184. * @param meshes The mesh to target.
  41185. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41186. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41187. */
  41188. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41189. /**
  41190. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41191. * @param minimumWorld Determines the smaller position of the bounding box extend
  41192. * @param maximumWorld Determines the bigger position of the bounding box extend
  41193. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41194. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41195. */
  41196. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41197. /**
  41198. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41199. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41200. * frustum width.
  41201. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41202. * to fully enclose the mesh in the viewing frustum.
  41203. */
  41204. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41205. /**
  41206. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41207. * is automatically returned to its default position (expected to be above ground plane).
  41208. */
  41209. private _maintainCameraAboveGround;
  41210. /**
  41211. * Returns the frustum slope based on the canvas ratio and camera FOV
  41212. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41213. */
  41214. private _getFrustumSlope;
  41215. /**
  41216. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41217. */
  41218. private _clearAnimationLocks;
  41219. /**
  41220. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41221. */
  41222. private _applyUserInteraction;
  41223. /**
  41224. * Stops and removes all animations that have been applied to the camera
  41225. */
  41226. stopAllAnimations(): void;
  41227. /**
  41228. * Gets a value indicating if the user is moving the camera
  41229. */
  41230. get isUserIsMoving(): boolean;
  41231. /**
  41232. * The camera can move all the way towards the mesh.
  41233. */
  41234. static IgnoreBoundsSizeMode: number;
  41235. /**
  41236. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41237. */
  41238. static FitFrustumSidesMode: number;
  41239. }
  41240. }
  41241. declare module BABYLON {
  41242. /**
  41243. * Base class for Camera Pointer Inputs.
  41244. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41245. * for example usage.
  41246. */
  41247. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41248. /**
  41249. * Defines the camera the input is attached to.
  41250. */
  41251. abstract camera: Camera;
  41252. /**
  41253. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41254. */
  41255. protected _altKey: boolean;
  41256. protected _ctrlKey: boolean;
  41257. protected _metaKey: boolean;
  41258. protected _shiftKey: boolean;
  41259. /**
  41260. * Which mouse buttons were pressed at time of last mouse event.
  41261. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41262. */
  41263. protected _buttonsPressed: number;
  41264. /**
  41265. * Defines the buttons associated with the input to handle camera move.
  41266. */
  41267. buttons: number[];
  41268. /**
  41269. * Attach the input controls to a specific dom element to get the input from.
  41270. * @param element Defines the element the controls should be listened from
  41271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41272. */
  41273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41274. /**
  41275. * Detach the current controls from the specified dom element.
  41276. * @param element Defines the element to stop listening the inputs from
  41277. */
  41278. detachControl(element: Nullable<HTMLElement>): void;
  41279. /**
  41280. * Gets the class name of the current input.
  41281. * @returns the class name
  41282. */
  41283. getClassName(): string;
  41284. /**
  41285. * Get the friendly name associated with the input class.
  41286. * @returns the input friendly name
  41287. */
  41288. getSimpleName(): string;
  41289. /**
  41290. * Called on pointer POINTERDOUBLETAP event.
  41291. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41292. */
  41293. protected onDoubleTap(type: string): void;
  41294. /**
  41295. * Called on pointer POINTERMOVE event if only a single touch is active.
  41296. * Override this method to provide functionality.
  41297. */
  41298. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41299. /**
  41300. * Called on pointer POINTERMOVE event if multiple touches are active.
  41301. * Override this method to provide functionality.
  41302. */
  41303. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41304. /**
  41305. * Called on JS contextmenu event.
  41306. * Override this method to provide functionality.
  41307. */
  41308. protected onContextMenu(evt: PointerEvent): void;
  41309. /**
  41310. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41311. * press.
  41312. * Override this method to provide functionality.
  41313. */
  41314. protected onButtonDown(evt: PointerEvent): void;
  41315. /**
  41316. * Called each time a new POINTERUP event occurs. Ie, for each button
  41317. * release.
  41318. * Override this method to provide functionality.
  41319. */
  41320. protected onButtonUp(evt: PointerEvent): void;
  41321. /**
  41322. * Called when window becomes inactive.
  41323. * Override this method to provide functionality.
  41324. */
  41325. protected onLostFocus(): void;
  41326. private _pointerInput;
  41327. private _observer;
  41328. private _onLostFocus;
  41329. private pointA;
  41330. private pointB;
  41331. }
  41332. }
  41333. declare module BABYLON {
  41334. /**
  41335. * Manage the pointers inputs to control an arc rotate camera.
  41336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41337. */
  41338. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41339. /**
  41340. * Defines the camera the input is attached to.
  41341. */
  41342. camera: ArcRotateCamera;
  41343. /**
  41344. * Gets the class name of the current input.
  41345. * @returns the class name
  41346. */
  41347. getClassName(): string;
  41348. /**
  41349. * Defines the buttons associated with the input to handle camera move.
  41350. */
  41351. buttons: number[];
  41352. /**
  41353. * Defines the pointer angular sensibility along the X axis or how fast is
  41354. * the camera rotating.
  41355. */
  41356. angularSensibilityX: number;
  41357. /**
  41358. * Defines the pointer angular sensibility along the Y axis or how fast is
  41359. * the camera rotating.
  41360. */
  41361. angularSensibilityY: number;
  41362. /**
  41363. * Defines the pointer pinch precision or how fast is the camera zooming.
  41364. */
  41365. pinchPrecision: number;
  41366. /**
  41367. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41368. * from 0.
  41369. * It defines the percentage of current camera.radius to use as delta when
  41370. * pinch zoom is used.
  41371. */
  41372. pinchDeltaPercentage: number;
  41373. /**
  41374. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41375. * that any object in the plane at the camera's target point will scale
  41376. * perfectly with finger motion.
  41377. * Overrides pinchDeltaPercentage and pinchPrecision.
  41378. */
  41379. useNaturalPinchZoom: boolean;
  41380. /**
  41381. * Defines the pointer panning sensibility or how fast is the camera moving.
  41382. */
  41383. panningSensibility: number;
  41384. /**
  41385. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41386. */
  41387. multiTouchPanning: boolean;
  41388. /**
  41389. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41390. * zoom (pinch) through multitouch.
  41391. */
  41392. multiTouchPanAndZoom: boolean;
  41393. /**
  41394. * Revers pinch action direction.
  41395. */
  41396. pinchInwards: boolean;
  41397. private _isPanClick;
  41398. private _twoFingerActivityCount;
  41399. private _isPinching;
  41400. /**
  41401. * Called on pointer POINTERMOVE event if only a single touch is active.
  41402. */
  41403. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41404. /**
  41405. * Called on pointer POINTERDOUBLETAP event.
  41406. */
  41407. protected onDoubleTap(type: string): void;
  41408. /**
  41409. * Called on pointer POINTERMOVE event if multiple touches are active.
  41410. */
  41411. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41412. /**
  41413. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41414. * press.
  41415. */
  41416. protected onButtonDown(evt: PointerEvent): void;
  41417. /**
  41418. * Called each time a new POINTERUP event occurs. Ie, for each button
  41419. * release.
  41420. */
  41421. protected onButtonUp(evt: PointerEvent): void;
  41422. /**
  41423. * Called when window becomes inactive.
  41424. */
  41425. protected onLostFocus(): void;
  41426. }
  41427. }
  41428. declare module BABYLON {
  41429. /**
  41430. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41431. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41432. */
  41433. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41434. /**
  41435. * Defines the camera the input is attached to.
  41436. */
  41437. camera: ArcRotateCamera;
  41438. /**
  41439. * Defines the list of key codes associated with the up action (increase alpha)
  41440. */
  41441. keysUp: number[];
  41442. /**
  41443. * Defines the list of key codes associated with the down action (decrease alpha)
  41444. */
  41445. keysDown: number[];
  41446. /**
  41447. * Defines the list of key codes associated with the left action (increase beta)
  41448. */
  41449. keysLeft: number[];
  41450. /**
  41451. * Defines the list of key codes associated with the right action (decrease beta)
  41452. */
  41453. keysRight: number[];
  41454. /**
  41455. * Defines the list of key codes associated with the reset action.
  41456. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41457. */
  41458. keysReset: number[];
  41459. /**
  41460. * Defines the panning sensibility of the inputs.
  41461. * (How fast is the camera panning)
  41462. */
  41463. panningSensibility: number;
  41464. /**
  41465. * Defines the zooming sensibility of the inputs.
  41466. * (How fast is the camera zooming)
  41467. */
  41468. zoomingSensibility: number;
  41469. /**
  41470. * Defines whether maintaining the alt key down switch the movement mode from
  41471. * orientation to zoom.
  41472. */
  41473. useAltToZoom: boolean;
  41474. /**
  41475. * Rotation speed of the camera
  41476. */
  41477. angularSpeed: number;
  41478. private _keys;
  41479. private _ctrlPressed;
  41480. private _altPressed;
  41481. private _onCanvasBlurObserver;
  41482. private _onKeyboardObserver;
  41483. private _engine;
  41484. private _scene;
  41485. /**
  41486. * Attach the input controls to a specific dom element to get the input from.
  41487. * @param element Defines the element the controls should be listened from
  41488. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41489. */
  41490. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41491. /**
  41492. * Detach the current controls from the specified dom element.
  41493. * @param element Defines the element to stop listening the inputs from
  41494. */
  41495. detachControl(element: Nullable<HTMLElement>): void;
  41496. /**
  41497. * Update the current camera state depending on the inputs that have been used this frame.
  41498. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41499. */
  41500. checkInputs(): void;
  41501. /**
  41502. * Gets the class name of the current intput.
  41503. * @returns the class name
  41504. */
  41505. getClassName(): string;
  41506. /**
  41507. * Get the friendly name associated with the input class.
  41508. * @returns the input friendly name
  41509. */
  41510. getSimpleName(): string;
  41511. }
  41512. }
  41513. declare module BABYLON {
  41514. /**
  41515. * Manage the mouse wheel inputs to control an arc rotate camera.
  41516. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41517. */
  41518. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41519. /**
  41520. * Defines the camera the input is attached to.
  41521. */
  41522. camera: ArcRotateCamera;
  41523. /**
  41524. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41525. */
  41526. wheelPrecision: number;
  41527. /**
  41528. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41529. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41530. */
  41531. wheelDeltaPercentage: number;
  41532. private _wheel;
  41533. private _observer;
  41534. private computeDeltaFromMouseWheelLegacyEvent;
  41535. /**
  41536. * Attach the input controls to a specific dom element to get the input from.
  41537. * @param element Defines the element the controls should be listened from
  41538. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41539. */
  41540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41541. /**
  41542. * Detach the current controls from the specified dom element.
  41543. * @param element Defines the element to stop listening the inputs from
  41544. */
  41545. detachControl(element: Nullable<HTMLElement>): void;
  41546. /**
  41547. * Gets the class name of the current intput.
  41548. * @returns the class name
  41549. */
  41550. getClassName(): string;
  41551. /**
  41552. * Get the friendly name associated with the input class.
  41553. * @returns the input friendly name
  41554. */
  41555. getSimpleName(): string;
  41556. }
  41557. }
  41558. declare module BABYLON {
  41559. /**
  41560. * Default Inputs manager for the ArcRotateCamera.
  41561. * It groups all the default supported inputs for ease of use.
  41562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41563. */
  41564. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41565. /**
  41566. * Instantiates a new ArcRotateCameraInputsManager.
  41567. * @param camera Defines the camera the inputs belong to
  41568. */
  41569. constructor(camera: ArcRotateCamera);
  41570. /**
  41571. * Add mouse wheel input support to the input manager.
  41572. * @returns the current input manager
  41573. */
  41574. addMouseWheel(): ArcRotateCameraInputsManager;
  41575. /**
  41576. * Add pointers input support to the input manager.
  41577. * @returns the current input manager
  41578. */
  41579. addPointers(): ArcRotateCameraInputsManager;
  41580. /**
  41581. * Add keyboard input support to the input manager.
  41582. * @returns the current input manager
  41583. */
  41584. addKeyboard(): ArcRotateCameraInputsManager;
  41585. }
  41586. }
  41587. declare module BABYLON {
  41588. /**
  41589. * This represents an orbital type of camera.
  41590. *
  41591. * 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.
  41592. * 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.
  41593. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41594. */
  41595. export class ArcRotateCamera extends TargetCamera {
  41596. /**
  41597. * Defines the rotation angle of the camera along the longitudinal axis.
  41598. */
  41599. alpha: number;
  41600. /**
  41601. * Defines the rotation angle of the camera along the latitudinal axis.
  41602. */
  41603. beta: number;
  41604. /**
  41605. * Defines the radius of the camera from it s target point.
  41606. */
  41607. radius: number;
  41608. protected _target: Vector3;
  41609. protected _targetHost: Nullable<AbstractMesh>;
  41610. /**
  41611. * Defines the target point of the camera.
  41612. * The camera looks towards it form the radius distance.
  41613. */
  41614. get target(): Vector3;
  41615. set target(value: Vector3);
  41616. /**
  41617. * Define the current local position of the camera in the scene
  41618. */
  41619. get position(): Vector3;
  41620. set position(newPosition: Vector3);
  41621. protected _upVector: Vector3;
  41622. protected _upToYMatrix: Matrix;
  41623. protected _YToUpMatrix: Matrix;
  41624. /**
  41625. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41626. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41627. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41628. */
  41629. set upVector(vec: Vector3);
  41630. get upVector(): Vector3;
  41631. /**
  41632. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41633. */
  41634. setMatUp(): void;
  41635. /**
  41636. * Current inertia value on the longitudinal axis.
  41637. * The bigger this number the longer it will take for the camera to stop.
  41638. */
  41639. inertialAlphaOffset: number;
  41640. /**
  41641. * Current inertia value on the latitudinal axis.
  41642. * The bigger this number the longer it will take for the camera to stop.
  41643. */
  41644. inertialBetaOffset: number;
  41645. /**
  41646. * Current inertia value on the radius axis.
  41647. * The bigger this number the longer it will take for the camera to stop.
  41648. */
  41649. inertialRadiusOffset: number;
  41650. /**
  41651. * Minimum allowed angle on the longitudinal axis.
  41652. * This can help limiting how the Camera is able to move in the scene.
  41653. */
  41654. lowerAlphaLimit: Nullable<number>;
  41655. /**
  41656. * Maximum allowed angle on the longitudinal axis.
  41657. * This can help limiting how the Camera is able to move in the scene.
  41658. */
  41659. upperAlphaLimit: Nullable<number>;
  41660. /**
  41661. * Minimum allowed angle on the latitudinal axis.
  41662. * This can help limiting how the Camera is able to move in the scene.
  41663. */
  41664. lowerBetaLimit: number;
  41665. /**
  41666. * Maximum allowed angle on the latitudinal axis.
  41667. * This can help limiting how the Camera is able to move in the scene.
  41668. */
  41669. upperBetaLimit: number;
  41670. /**
  41671. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41672. * This can help limiting how the Camera is able to move in the scene.
  41673. */
  41674. lowerRadiusLimit: Nullable<number>;
  41675. /**
  41676. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41677. * This can help limiting how the Camera is able to move in the scene.
  41678. */
  41679. upperRadiusLimit: Nullable<number>;
  41680. /**
  41681. * Defines the current inertia value used during panning of the camera along the X axis.
  41682. */
  41683. inertialPanningX: number;
  41684. /**
  41685. * Defines the current inertia value used during panning of the camera along the Y axis.
  41686. */
  41687. inertialPanningY: number;
  41688. /**
  41689. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41690. * Basically if your fingers moves away from more than this distance you will be considered
  41691. * in pinch mode.
  41692. */
  41693. pinchToPanMaxDistance: number;
  41694. /**
  41695. * Defines the maximum distance the camera can pan.
  41696. * This could help keeping the cammera always in your scene.
  41697. */
  41698. panningDistanceLimit: Nullable<number>;
  41699. /**
  41700. * Defines the target of the camera before paning.
  41701. */
  41702. panningOriginTarget: Vector3;
  41703. /**
  41704. * Defines the value of the inertia used during panning.
  41705. * 0 would mean stop inertia and one would mean no decelleration at all.
  41706. */
  41707. panningInertia: number;
  41708. /**
  41709. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41710. */
  41711. get angularSensibilityX(): number;
  41712. set angularSensibilityX(value: number);
  41713. /**
  41714. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41715. */
  41716. get angularSensibilityY(): number;
  41717. set angularSensibilityY(value: number);
  41718. /**
  41719. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41720. */
  41721. get pinchPrecision(): number;
  41722. set pinchPrecision(value: number);
  41723. /**
  41724. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41725. * It will be used instead of pinchDeltaPrecision if different from 0.
  41726. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41727. */
  41728. get pinchDeltaPercentage(): number;
  41729. set pinchDeltaPercentage(value: number);
  41730. /**
  41731. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41732. * and pinch delta percentage.
  41733. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41734. * that any object in the plane at the camera's target point will scale
  41735. * perfectly with finger motion.
  41736. */
  41737. get useNaturalPinchZoom(): boolean;
  41738. set useNaturalPinchZoom(value: boolean);
  41739. /**
  41740. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41741. */
  41742. get panningSensibility(): number;
  41743. set panningSensibility(value: number);
  41744. /**
  41745. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41746. */
  41747. get keysUp(): number[];
  41748. set keysUp(value: number[]);
  41749. /**
  41750. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41751. */
  41752. get keysDown(): number[];
  41753. set keysDown(value: number[]);
  41754. /**
  41755. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41756. */
  41757. get keysLeft(): number[];
  41758. set keysLeft(value: number[]);
  41759. /**
  41760. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41761. */
  41762. get keysRight(): number[];
  41763. set keysRight(value: number[]);
  41764. /**
  41765. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41766. */
  41767. get wheelPrecision(): number;
  41768. set wheelPrecision(value: number);
  41769. /**
  41770. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41771. * It will be used instead of pinchDeltaPrecision if different from 0.
  41772. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41773. */
  41774. get wheelDeltaPercentage(): number;
  41775. set wheelDeltaPercentage(value: number);
  41776. /**
  41777. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41778. */
  41779. zoomOnFactor: number;
  41780. /**
  41781. * Defines a screen offset for the camera position.
  41782. */
  41783. targetScreenOffset: Vector2;
  41784. /**
  41785. * Allows the camera to be completely reversed.
  41786. * If false the camera can not arrive upside down.
  41787. */
  41788. allowUpsideDown: boolean;
  41789. /**
  41790. * Define if double tap/click is used to restore the previously saved state of the camera.
  41791. */
  41792. useInputToRestoreState: boolean;
  41793. /** @hidden */
  41794. _viewMatrix: Matrix;
  41795. /** @hidden */
  41796. _useCtrlForPanning: boolean;
  41797. /** @hidden */
  41798. _panningMouseButton: number;
  41799. /**
  41800. * Defines the input associated to the camera.
  41801. */
  41802. inputs: ArcRotateCameraInputsManager;
  41803. /** @hidden */
  41804. _reset: () => void;
  41805. /**
  41806. * Defines the allowed panning axis.
  41807. */
  41808. panningAxis: Vector3;
  41809. protected _localDirection: Vector3;
  41810. protected _transformedDirection: Vector3;
  41811. private _bouncingBehavior;
  41812. /**
  41813. * Gets the bouncing behavior of the camera if it has been enabled.
  41814. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41815. */
  41816. get bouncingBehavior(): Nullable<BouncingBehavior>;
  41817. /**
  41818. * Defines if the bouncing behavior of the camera is enabled on the camera.
  41819. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41820. */
  41821. get useBouncingBehavior(): boolean;
  41822. set useBouncingBehavior(value: boolean);
  41823. private _framingBehavior;
  41824. /**
  41825. * Gets the framing behavior of the camera if it has been enabled.
  41826. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41827. */
  41828. get framingBehavior(): Nullable<FramingBehavior>;
  41829. /**
  41830. * Defines if the framing behavior of the camera is enabled on the camera.
  41831. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41832. */
  41833. get useFramingBehavior(): boolean;
  41834. set useFramingBehavior(value: boolean);
  41835. private _autoRotationBehavior;
  41836. /**
  41837. * Gets the auto rotation behavior of the camera if it has been enabled.
  41838. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41839. */
  41840. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  41841. /**
  41842. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  41843. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41844. */
  41845. get useAutoRotationBehavior(): boolean;
  41846. set useAutoRotationBehavior(value: boolean);
  41847. /**
  41848. * Observable triggered when the mesh target has been changed on the camera.
  41849. */
  41850. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  41851. /**
  41852. * Event raised when the camera is colliding with a mesh.
  41853. */
  41854. onCollide: (collidedMesh: AbstractMesh) => void;
  41855. /**
  41856. * Defines whether the camera should check collision with the objects oh the scene.
  41857. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  41858. */
  41859. checkCollisions: boolean;
  41860. /**
  41861. * Defines the collision radius of the camera.
  41862. * This simulates a sphere around the camera.
  41863. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41864. */
  41865. collisionRadius: Vector3;
  41866. protected _collider: Collider;
  41867. protected _previousPosition: Vector3;
  41868. protected _collisionVelocity: Vector3;
  41869. protected _newPosition: Vector3;
  41870. protected _previousAlpha: number;
  41871. protected _previousBeta: number;
  41872. protected _previousRadius: number;
  41873. protected _collisionTriggered: boolean;
  41874. protected _targetBoundingCenter: Nullable<Vector3>;
  41875. private _computationVector;
  41876. /**
  41877. * Instantiates a new ArcRotateCamera in a given scene
  41878. * @param name Defines the name of the camera
  41879. * @param alpha Defines the camera rotation along the logitudinal axis
  41880. * @param beta Defines the camera rotation along the latitudinal axis
  41881. * @param radius Defines the camera distance from its target
  41882. * @param target Defines the camera target
  41883. * @param scene Defines the scene the camera belongs to
  41884. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  41885. */
  41886. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41887. /** @hidden */
  41888. _initCache(): void;
  41889. /** @hidden */
  41890. _updateCache(ignoreParentClass?: boolean): void;
  41891. protected _getTargetPosition(): Vector3;
  41892. private _storedAlpha;
  41893. private _storedBeta;
  41894. private _storedRadius;
  41895. private _storedTarget;
  41896. private _storedTargetScreenOffset;
  41897. /**
  41898. * Stores the current state of the camera (alpha, beta, radius and target)
  41899. * @returns the camera itself
  41900. */
  41901. storeState(): Camera;
  41902. /**
  41903. * @hidden
  41904. * Restored camera state. You must call storeState() first
  41905. */
  41906. _restoreStateValues(): boolean;
  41907. /** @hidden */
  41908. _isSynchronizedViewMatrix(): boolean;
  41909. /**
  41910. * Attached controls to the current camera.
  41911. * @param element Defines the element the controls should be listened from
  41912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41913. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  41914. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  41915. */
  41916. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  41917. /**
  41918. * Detach the current controls from the camera.
  41919. * The camera will stop reacting to inputs.
  41920. * @param element Defines the element to stop listening the inputs from
  41921. */
  41922. detachControl(element: HTMLElement): void;
  41923. /** @hidden */
  41924. _checkInputs(): void;
  41925. protected _checkLimits(): void;
  41926. /**
  41927. * Rebuilds angles (alpha, beta) and radius from the give position and target
  41928. */
  41929. rebuildAnglesAndRadius(): void;
  41930. /**
  41931. * Use a position to define the current camera related information like alpha, beta and radius
  41932. * @param position Defines the position to set the camera at
  41933. */
  41934. setPosition(position: Vector3): void;
  41935. /**
  41936. * Defines the target the camera should look at.
  41937. * This will automatically adapt alpha beta and radius to fit within the new target.
  41938. * @param target Defines the new target as a Vector or a mesh
  41939. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  41940. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  41941. */
  41942. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  41943. /** @hidden */
  41944. _getViewMatrix(): Matrix;
  41945. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  41946. /**
  41947. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  41948. * @param meshes Defines the mesh to zoom on
  41949. * @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)
  41950. */
  41951. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  41952. /**
  41953. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  41954. * The target will be changed but the radius
  41955. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  41956. * @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)
  41957. */
  41958. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  41959. min: Vector3;
  41960. max: Vector3;
  41961. distance: number;
  41962. }, doNotUpdateMaxZ?: boolean): void;
  41963. /**
  41964. * @override
  41965. * Override Camera.createRigCamera
  41966. */
  41967. createRigCamera(name: string, cameraIndex: number): Camera;
  41968. /**
  41969. * @hidden
  41970. * @override
  41971. * Override Camera._updateRigCameras
  41972. */
  41973. _updateRigCameras(): void;
  41974. /**
  41975. * Destroy the camera and release the current resources hold by it.
  41976. */
  41977. dispose(): void;
  41978. /**
  41979. * Gets the current object class name.
  41980. * @return the class name
  41981. */
  41982. getClassName(): string;
  41983. }
  41984. }
  41985. declare module BABYLON {
  41986. /**
  41987. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  41988. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41989. */
  41990. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  41991. /**
  41992. * Gets the name of the behavior.
  41993. */
  41994. get name(): string;
  41995. private _zoomStopsAnimation;
  41996. private _idleRotationSpeed;
  41997. private _idleRotationWaitTime;
  41998. private _idleRotationSpinupTime;
  41999. /**
  42000. * Sets the flag that indicates if user zooming should stop animation.
  42001. */
  42002. set zoomStopsAnimation(flag: boolean);
  42003. /**
  42004. * Gets the flag that indicates if user zooming should stop animation.
  42005. */
  42006. get zoomStopsAnimation(): boolean;
  42007. /**
  42008. * Sets the default speed at which the camera rotates around the model.
  42009. */
  42010. set idleRotationSpeed(speed: number);
  42011. /**
  42012. * Gets the default speed at which the camera rotates around the model.
  42013. */
  42014. get idleRotationSpeed(): number;
  42015. /**
  42016. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42017. */
  42018. set idleRotationWaitTime(time: number);
  42019. /**
  42020. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42021. */
  42022. get idleRotationWaitTime(): number;
  42023. /**
  42024. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42025. */
  42026. set idleRotationSpinupTime(time: number);
  42027. /**
  42028. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42029. */
  42030. get idleRotationSpinupTime(): number;
  42031. /**
  42032. * Gets a value indicating if the camera is currently rotating because of this behavior
  42033. */
  42034. get rotationInProgress(): boolean;
  42035. private _onPrePointerObservableObserver;
  42036. private _onAfterCheckInputsObserver;
  42037. private _attachedCamera;
  42038. private _isPointerDown;
  42039. private _lastFrameTime;
  42040. private _lastInteractionTime;
  42041. private _cameraRotationSpeed;
  42042. /**
  42043. * Initializes the behavior.
  42044. */
  42045. init(): void;
  42046. /**
  42047. * Attaches the behavior to its arc rotate camera.
  42048. * @param camera Defines the camera to attach the behavior to
  42049. */
  42050. attach(camera: ArcRotateCamera): void;
  42051. /**
  42052. * Detaches the behavior from its current arc rotate camera.
  42053. */
  42054. detach(): void;
  42055. /**
  42056. * Returns true if user is scrolling.
  42057. * @return true if user is scrolling.
  42058. */
  42059. private _userIsZooming;
  42060. private _lastFrameRadius;
  42061. private _shouldAnimationStopForInteraction;
  42062. /**
  42063. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42064. */
  42065. private _applyUserInteraction;
  42066. private _userIsMoving;
  42067. }
  42068. }
  42069. declare module BABYLON {
  42070. /**
  42071. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42072. */
  42073. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42074. private ui;
  42075. /**
  42076. * The name of the behavior
  42077. */
  42078. name: string;
  42079. /**
  42080. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42081. */
  42082. distanceAwayFromFace: number;
  42083. /**
  42084. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42085. */
  42086. distanceAwayFromBottomOfFace: number;
  42087. private _faceVectors;
  42088. private _target;
  42089. private _scene;
  42090. private _onRenderObserver;
  42091. private _tmpMatrix;
  42092. private _tmpVector;
  42093. /**
  42094. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42095. * @param ui The transform node that should be attched to the mesh
  42096. */
  42097. constructor(ui: TransformNode);
  42098. /**
  42099. * Initializes the behavior
  42100. */
  42101. init(): void;
  42102. private _closestFace;
  42103. private _zeroVector;
  42104. private _lookAtTmpMatrix;
  42105. private _lookAtToRef;
  42106. /**
  42107. * Attaches the AttachToBoxBehavior to the passed in mesh
  42108. * @param target The mesh that the specified node will be attached to
  42109. */
  42110. attach(target: Mesh): void;
  42111. /**
  42112. * Detaches the behavior from the mesh
  42113. */
  42114. detach(): void;
  42115. }
  42116. }
  42117. declare module BABYLON {
  42118. /**
  42119. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42120. */
  42121. export class FadeInOutBehavior implements Behavior<Mesh> {
  42122. /**
  42123. * Time in milliseconds to delay before fading in (Default: 0)
  42124. */
  42125. delay: number;
  42126. /**
  42127. * Time in milliseconds for the mesh to fade in (Default: 300)
  42128. */
  42129. fadeInTime: number;
  42130. private _millisecondsPerFrame;
  42131. private _hovered;
  42132. private _hoverValue;
  42133. private _ownerNode;
  42134. /**
  42135. * Instatiates the FadeInOutBehavior
  42136. */
  42137. constructor();
  42138. /**
  42139. * The name of the behavior
  42140. */
  42141. get name(): string;
  42142. /**
  42143. * Initializes the behavior
  42144. */
  42145. init(): void;
  42146. /**
  42147. * Attaches the fade behavior on the passed in mesh
  42148. * @param ownerNode The mesh that will be faded in/out once attached
  42149. */
  42150. attach(ownerNode: Mesh): void;
  42151. /**
  42152. * Detaches the behavior from the mesh
  42153. */
  42154. detach(): void;
  42155. /**
  42156. * Triggers the mesh to begin fading in or out
  42157. * @param value if the object should fade in or out (true to fade in)
  42158. */
  42159. fadeIn(value: boolean): void;
  42160. private _update;
  42161. private _setAllVisibility;
  42162. }
  42163. }
  42164. declare module BABYLON {
  42165. /**
  42166. * Class containing a set of static utilities functions for managing Pivots
  42167. * @hidden
  42168. */
  42169. export class PivotTools {
  42170. private static _PivotCached;
  42171. private static _OldPivotPoint;
  42172. private static _PivotTranslation;
  42173. private static _PivotTmpVector;
  42174. /** @hidden */
  42175. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42176. /** @hidden */
  42177. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42178. }
  42179. }
  42180. declare module BABYLON {
  42181. /**
  42182. * Class containing static functions to help procedurally build meshes
  42183. */
  42184. export class PlaneBuilder {
  42185. /**
  42186. * Creates a plane mesh
  42187. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42188. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42189. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42191. * * 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
  42192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42193. * @param name defines the name of the mesh
  42194. * @param options defines the options used to create the mesh
  42195. * @param scene defines the hosting scene
  42196. * @returns the plane mesh
  42197. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42198. */
  42199. static CreatePlane(name: string, options: {
  42200. size?: number;
  42201. width?: number;
  42202. height?: number;
  42203. sideOrientation?: number;
  42204. frontUVs?: Vector4;
  42205. backUVs?: Vector4;
  42206. updatable?: boolean;
  42207. sourcePlane?: Plane;
  42208. }, scene?: Nullable<Scene>): Mesh;
  42209. }
  42210. }
  42211. declare module BABYLON {
  42212. /**
  42213. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42214. */
  42215. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42216. private static _AnyMouseID;
  42217. /**
  42218. * Abstract mesh the behavior is set on
  42219. */
  42220. attachedNode: AbstractMesh;
  42221. private _dragPlane;
  42222. private _scene;
  42223. private _pointerObserver;
  42224. private _beforeRenderObserver;
  42225. private static _planeScene;
  42226. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42227. /**
  42228. * 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)
  42229. */
  42230. maxDragAngle: number;
  42231. /**
  42232. * @hidden
  42233. */
  42234. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42235. /**
  42236. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42237. */
  42238. currentDraggingPointerID: number;
  42239. /**
  42240. * The last position where the pointer hit the drag plane in world space
  42241. */
  42242. lastDragPosition: Vector3;
  42243. /**
  42244. * If the behavior is currently in a dragging state
  42245. */
  42246. dragging: boolean;
  42247. /**
  42248. * 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)
  42249. */
  42250. dragDeltaRatio: number;
  42251. /**
  42252. * If the drag plane orientation should be updated during the dragging (Default: true)
  42253. */
  42254. updateDragPlane: boolean;
  42255. private _debugMode;
  42256. private _moving;
  42257. /**
  42258. * Fires each time the attached mesh is dragged with the pointer
  42259. * * delta between last drag position and current drag position in world space
  42260. * * dragDistance along the drag axis
  42261. * * dragPlaneNormal normal of the current drag plane used during the drag
  42262. * * dragPlanePoint in world space where the drag intersects the drag plane
  42263. */
  42264. onDragObservable: Observable<{
  42265. delta: Vector3;
  42266. dragPlanePoint: Vector3;
  42267. dragPlaneNormal: Vector3;
  42268. dragDistance: number;
  42269. pointerId: number;
  42270. }>;
  42271. /**
  42272. * Fires each time a drag begins (eg. mouse down on mesh)
  42273. */
  42274. onDragStartObservable: Observable<{
  42275. dragPlanePoint: Vector3;
  42276. pointerId: number;
  42277. }>;
  42278. /**
  42279. * Fires each time a drag ends (eg. mouse release after drag)
  42280. */
  42281. onDragEndObservable: Observable<{
  42282. dragPlanePoint: Vector3;
  42283. pointerId: number;
  42284. }>;
  42285. /**
  42286. * If the attached mesh should be moved when dragged
  42287. */
  42288. moveAttached: boolean;
  42289. /**
  42290. * If the drag behavior will react to drag events (Default: true)
  42291. */
  42292. enabled: boolean;
  42293. /**
  42294. * If pointer events should start and release the drag (Default: true)
  42295. */
  42296. startAndReleaseDragOnPointerEvents: boolean;
  42297. /**
  42298. * If camera controls should be detached during the drag
  42299. */
  42300. detachCameraControls: boolean;
  42301. /**
  42302. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42303. */
  42304. useObjectOrientationForDragging: boolean;
  42305. private _options;
  42306. /**
  42307. * Gets the options used by the behavior
  42308. */
  42309. get options(): {
  42310. dragAxis?: Vector3;
  42311. dragPlaneNormal?: Vector3;
  42312. };
  42313. /**
  42314. * Sets the options used by the behavior
  42315. */
  42316. set options(options: {
  42317. dragAxis?: Vector3;
  42318. dragPlaneNormal?: Vector3;
  42319. });
  42320. /**
  42321. * Creates a pointer drag behavior that can be attached to a mesh
  42322. * @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)
  42323. */
  42324. constructor(options?: {
  42325. dragAxis?: Vector3;
  42326. dragPlaneNormal?: Vector3;
  42327. });
  42328. /**
  42329. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42330. */
  42331. validateDrag: (targetPosition: Vector3) => boolean;
  42332. /**
  42333. * The name of the behavior
  42334. */
  42335. get name(): string;
  42336. /**
  42337. * Initializes the behavior
  42338. */
  42339. init(): void;
  42340. private _tmpVector;
  42341. private _alternatePickedPoint;
  42342. private _worldDragAxis;
  42343. private _targetPosition;
  42344. private _attachedElement;
  42345. /**
  42346. * Attaches the drag behavior the passed in mesh
  42347. * @param ownerNode The mesh that will be dragged around once attached
  42348. * @param predicate Predicate to use for pick filtering
  42349. */
  42350. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42351. /**
  42352. * Force relase the drag action by code.
  42353. */
  42354. releaseDrag(): void;
  42355. private _startDragRay;
  42356. private _lastPointerRay;
  42357. /**
  42358. * Simulates the start of a pointer drag event on the behavior
  42359. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42360. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42361. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42362. */
  42363. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42364. private _startDrag;
  42365. private _dragDelta;
  42366. private _moveDrag;
  42367. private _pickWithRayOnDragPlane;
  42368. private _pointA;
  42369. private _pointB;
  42370. private _pointC;
  42371. private _lineA;
  42372. private _lineB;
  42373. private _localAxis;
  42374. private _lookAt;
  42375. private _updateDragPlanePosition;
  42376. /**
  42377. * Detaches the behavior from the mesh
  42378. */
  42379. detach(): void;
  42380. }
  42381. }
  42382. declare module BABYLON {
  42383. /**
  42384. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42385. */
  42386. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42387. private _dragBehaviorA;
  42388. private _dragBehaviorB;
  42389. private _startDistance;
  42390. private _initialScale;
  42391. private _targetScale;
  42392. private _ownerNode;
  42393. private _sceneRenderObserver;
  42394. /**
  42395. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42396. */
  42397. constructor();
  42398. /**
  42399. * The name of the behavior
  42400. */
  42401. get name(): string;
  42402. /**
  42403. * Initializes the behavior
  42404. */
  42405. init(): void;
  42406. private _getCurrentDistance;
  42407. /**
  42408. * Attaches the scale behavior the passed in mesh
  42409. * @param ownerNode The mesh that will be scaled around once attached
  42410. */
  42411. attach(ownerNode: Mesh): void;
  42412. /**
  42413. * Detaches the behavior from the mesh
  42414. */
  42415. detach(): void;
  42416. }
  42417. }
  42418. declare module BABYLON {
  42419. /**
  42420. * 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
  42421. */
  42422. export class SixDofDragBehavior implements Behavior<Mesh> {
  42423. private static _virtualScene;
  42424. private _ownerNode;
  42425. private _sceneRenderObserver;
  42426. private _scene;
  42427. private _targetPosition;
  42428. private _virtualOriginMesh;
  42429. private _virtualDragMesh;
  42430. private _pointerObserver;
  42431. private _moving;
  42432. private _startingOrientation;
  42433. private _attachedElement;
  42434. /**
  42435. * 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)
  42436. */
  42437. private zDragFactor;
  42438. /**
  42439. * If the object should rotate to face the drag origin
  42440. */
  42441. rotateDraggedObject: boolean;
  42442. /**
  42443. * If the behavior is currently in a dragging state
  42444. */
  42445. dragging: boolean;
  42446. /**
  42447. * 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)
  42448. */
  42449. dragDeltaRatio: number;
  42450. /**
  42451. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42452. */
  42453. currentDraggingPointerID: number;
  42454. /**
  42455. * If camera controls should be detached during the drag
  42456. */
  42457. detachCameraControls: boolean;
  42458. /**
  42459. * Fires each time a drag starts
  42460. */
  42461. onDragStartObservable: Observable<{}>;
  42462. /**
  42463. * Fires each time a drag ends (eg. mouse release after drag)
  42464. */
  42465. onDragEndObservable: Observable<{}>;
  42466. /**
  42467. * 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
  42468. */
  42469. constructor();
  42470. /**
  42471. * The name of the behavior
  42472. */
  42473. get name(): string;
  42474. /**
  42475. * Initializes the behavior
  42476. */
  42477. init(): void;
  42478. /**
  42479. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42480. */
  42481. private get _pointerCamera();
  42482. /**
  42483. * Attaches the scale behavior the passed in mesh
  42484. * @param ownerNode The mesh that will be scaled around once attached
  42485. */
  42486. attach(ownerNode: Mesh): void;
  42487. /**
  42488. * Detaches the behavior from the mesh
  42489. */
  42490. detach(): void;
  42491. }
  42492. }
  42493. declare module BABYLON {
  42494. /**
  42495. * Class used to apply inverse kinematics to bones
  42496. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42497. */
  42498. export class BoneIKController {
  42499. private static _tmpVecs;
  42500. private static _tmpQuat;
  42501. private static _tmpMats;
  42502. /**
  42503. * Gets or sets the target mesh
  42504. */
  42505. targetMesh: AbstractMesh;
  42506. /** Gets or sets the mesh used as pole */
  42507. poleTargetMesh: AbstractMesh;
  42508. /**
  42509. * Gets or sets the bone used as pole
  42510. */
  42511. poleTargetBone: Nullable<Bone>;
  42512. /**
  42513. * Gets or sets the target position
  42514. */
  42515. targetPosition: Vector3;
  42516. /**
  42517. * Gets or sets the pole target position
  42518. */
  42519. poleTargetPosition: Vector3;
  42520. /**
  42521. * Gets or sets the pole target local offset
  42522. */
  42523. poleTargetLocalOffset: Vector3;
  42524. /**
  42525. * Gets or sets the pole angle
  42526. */
  42527. poleAngle: number;
  42528. /**
  42529. * Gets or sets the mesh associated with the controller
  42530. */
  42531. mesh: AbstractMesh;
  42532. /**
  42533. * 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)
  42534. */
  42535. slerpAmount: number;
  42536. private _bone1Quat;
  42537. private _bone1Mat;
  42538. private _bone2Ang;
  42539. private _bone1;
  42540. private _bone2;
  42541. private _bone1Length;
  42542. private _bone2Length;
  42543. private _maxAngle;
  42544. private _maxReach;
  42545. private _rightHandedSystem;
  42546. private _bendAxis;
  42547. private _slerping;
  42548. private _adjustRoll;
  42549. /**
  42550. * Gets or sets maximum allowed angle
  42551. */
  42552. get maxAngle(): number;
  42553. set maxAngle(value: number);
  42554. /**
  42555. * Creates a new BoneIKController
  42556. * @param mesh defines the mesh to control
  42557. * @param bone defines the bone to control
  42558. * @param options defines options to set up the controller
  42559. */
  42560. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42561. targetMesh?: AbstractMesh;
  42562. poleTargetMesh?: AbstractMesh;
  42563. poleTargetBone?: Bone;
  42564. poleTargetLocalOffset?: Vector3;
  42565. poleAngle?: number;
  42566. bendAxis?: Vector3;
  42567. maxAngle?: number;
  42568. slerpAmount?: number;
  42569. });
  42570. private _setMaxAngle;
  42571. /**
  42572. * Force the controller to update the bones
  42573. */
  42574. update(): void;
  42575. }
  42576. }
  42577. declare module BABYLON {
  42578. /**
  42579. * Class used to make a bone look toward a point in space
  42580. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42581. */
  42582. export class BoneLookController {
  42583. private static _tmpVecs;
  42584. private static _tmpQuat;
  42585. private static _tmpMats;
  42586. /**
  42587. * The target Vector3 that the bone will look at
  42588. */
  42589. target: Vector3;
  42590. /**
  42591. * The mesh that the bone is attached to
  42592. */
  42593. mesh: AbstractMesh;
  42594. /**
  42595. * The bone that will be looking to the target
  42596. */
  42597. bone: Bone;
  42598. /**
  42599. * The up axis of the coordinate system that is used when the bone is rotated
  42600. */
  42601. upAxis: Vector3;
  42602. /**
  42603. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42604. */
  42605. upAxisSpace: Space;
  42606. /**
  42607. * Used to make an adjustment to the yaw of the bone
  42608. */
  42609. adjustYaw: number;
  42610. /**
  42611. * Used to make an adjustment to the pitch of the bone
  42612. */
  42613. adjustPitch: number;
  42614. /**
  42615. * Used to make an adjustment to the roll of the bone
  42616. */
  42617. adjustRoll: number;
  42618. /**
  42619. * 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)
  42620. */
  42621. slerpAmount: number;
  42622. private _minYaw;
  42623. private _maxYaw;
  42624. private _minPitch;
  42625. private _maxPitch;
  42626. private _minYawSin;
  42627. private _minYawCos;
  42628. private _maxYawSin;
  42629. private _maxYawCos;
  42630. private _midYawConstraint;
  42631. private _minPitchTan;
  42632. private _maxPitchTan;
  42633. private _boneQuat;
  42634. private _slerping;
  42635. private _transformYawPitch;
  42636. private _transformYawPitchInv;
  42637. private _firstFrameSkipped;
  42638. private _yawRange;
  42639. private _fowardAxis;
  42640. /**
  42641. * Gets or sets the minimum yaw angle that the bone can look to
  42642. */
  42643. get minYaw(): number;
  42644. set minYaw(value: number);
  42645. /**
  42646. * Gets or sets the maximum yaw angle that the bone can look to
  42647. */
  42648. get maxYaw(): number;
  42649. set maxYaw(value: number);
  42650. /**
  42651. * Gets or sets the minimum pitch angle that the bone can look to
  42652. */
  42653. get minPitch(): number;
  42654. set minPitch(value: number);
  42655. /**
  42656. * Gets or sets the maximum pitch angle that the bone can look to
  42657. */
  42658. get maxPitch(): number;
  42659. set maxPitch(value: number);
  42660. /**
  42661. * Create a BoneLookController
  42662. * @param mesh the mesh that the bone belongs to
  42663. * @param bone the bone that will be looking to the target
  42664. * @param target the target Vector3 to look at
  42665. * @param options optional settings:
  42666. * * maxYaw: the maximum angle the bone will yaw to
  42667. * * minYaw: the minimum angle the bone will yaw to
  42668. * * maxPitch: the maximum angle the bone will pitch to
  42669. * * minPitch: the minimum angle the bone will yaw to
  42670. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42671. * * upAxis: the up axis of the coordinate system
  42672. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42673. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42674. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42675. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42676. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42677. * * adjustRoll: used to make an adjustment to the roll of the bone
  42678. **/
  42679. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42680. maxYaw?: number;
  42681. minYaw?: number;
  42682. maxPitch?: number;
  42683. minPitch?: number;
  42684. slerpAmount?: number;
  42685. upAxis?: Vector3;
  42686. upAxisSpace?: Space;
  42687. yawAxis?: Vector3;
  42688. pitchAxis?: Vector3;
  42689. adjustYaw?: number;
  42690. adjustPitch?: number;
  42691. adjustRoll?: number;
  42692. });
  42693. /**
  42694. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42695. */
  42696. update(): void;
  42697. private _getAngleDiff;
  42698. private _getAngleBetween;
  42699. private _isAngleBetween;
  42700. }
  42701. }
  42702. declare module BABYLON {
  42703. /**
  42704. * Manage the gamepad inputs to control an arc rotate camera.
  42705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42706. */
  42707. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42708. /**
  42709. * Defines the camera the input is attached to.
  42710. */
  42711. camera: ArcRotateCamera;
  42712. /**
  42713. * Defines the gamepad the input is gathering event from.
  42714. */
  42715. gamepad: Nullable<Gamepad>;
  42716. /**
  42717. * Defines the gamepad rotation sensiblity.
  42718. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42719. */
  42720. gamepadRotationSensibility: number;
  42721. /**
  42722. * Defines the gamepad move sensiblity.
  42723. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42724. */
  42725. gamepadMoveSensibility: number;
  42726. private _yAxisScale;
  42727. /**
  42728. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42729. */
  42730. get invertYAxis(): boolean;
  42731. set invertYAxis(value: boolean);
  42732. private _onGamepadConnectedObserver;
  42733. private _onGamepadDisconnectedObserver;
  42734. /**
  42735. * Attach the input controls to a specific dom element to get the input from.
  42736. * @param element Defines the element the controls should be listened from
  42737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42738. */
  42739. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42740. /**
  42741. * Detach the current controls from the specified dom element.
  42742. * @param element Defines the element to stop listening the inputs from
  42743. */
  42744. detachControl(element: Nullable<HTMLElement>): void;
  42745. /**
  42746. * Update the current camera state depending on the inputs that have been used this frame.
  42747. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42748. */
  42749. checkInputs(): void;
  42750. /**
  42751. * Gets the class name of the current intput.
  42752. * @returns the class name
  42753. */
  42754. getClassName(): string;
  42755. /**
  42756. * Get the friendly name associated with the input class.
  42757. * @returns the input friendly name
  42758. */
  42759. getSimpleName(): string;
  42760. }
  42761. }
  42762. declare module BABYLON {
  42763. interface ArcRotateCameraInputsManager {
  42764. /**
  42765. * Add orientation input support to the input manager.
  42766. * @returns the current input manager
  42767. */
  42768. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42769. }
  42770. /**
  42771. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42772. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42773. */
  42774. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42775. /**
  42776. * Defines the camera the input is attached to.
  42777. */
  42778. camera: ArcRotateCamera;
  42779. /**
  42780. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42781. */
  42782. alphaCorrection: number;
  42783. /**
  42784. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42785. */
  42786. gammaCorrection: number;
  42787. private _alpha;
  42788. private _gamma;
  42789. private _dirty;
  42790. private _deviceOrientationHandler;
  42791. /**
  42792. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42793. */
  42794. constructor();
  42795. /**
  42796. * Attach the input controls to a specific dom element to get the input from.
  42797. * @param element Defines the element the controls should be listened from
  42798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42799. */
  42800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42801. /** @hidden */
  42802. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42803. /**
  42804. * Update the current camera state depending on the inputs that have been used this frame.
  42805. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42806. */
  42807. checkInputs(): void;
  42808. /**
  42809. * Detach the current controls from the specified dom element.
  42810. * @param element Defines the element to stop listening the inputs from
  42811. */
  42812. detachControl(element: Nullable<HTMLElement>): void;
  42813. /**
  42814. * Gets the class name of the current intput.
  42815. * @returns the class name
  42816. */
  42817. getClassName(): string;
  42818. /**
  42819. * Get the friendly name associated with the input class.
  42820. * @returns the input friendly name
  42821. */
  42822. getSimpleName(): string;
  42823. }
  42824. }
  42825. declare module BABYLON {
  42826. /**
  42827. * Listen to mouse events to control the camera.
  42828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42829. */
  42830. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42831. /**
  42832. * Defines the camera the input is attached to.
  42833. */
  42834. camera: FlyCamera;
  42835. /**
  42836. * Defines if touch is enabled. (Default is true.)
  42837. */
  42838. touchEnabled: boolean;
  42839. /**
  42840. * Defines the buttons associated with the input to handle camera rotation.
  42841. */
  42842. buttons: number[];
  42843. /**
  42844. * Assign buttons for Yaw control.
  42845. */
  42846. buttonsYaw: number[];
  42847. /**
  42848. * Assign buttons for Pitch control.
  42849. */
  42850. buttonsPitch: number[];
  42851. /**
  42852. * Assign buttons for Roll control.
  42853. */
  42854. buttonsRoll: number[];
  42855. /**
  42856. * Detect if any button is being pressed while mouse is moved.
  42857. * -1 = Mouse locked.
  42858. * 0 = Left button.
  42859. * 1 = Middle Button.
  42860. * 2 = Right Button.
  42861. */
  42862. activeButton: number;
  42863. /**
  42864. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42865. * Higher values reduce its sensitivity.
  42866. */
  42867. angularSensibility: number;
  42868. private _mousemoveCallback;
  42869. private _observer;
  42870. private _rollObserver;
  42871. private previousPosition;
  42872. private noPreventDefault;
  42873. private element;
  42874. /**
  42875. * Listen to mouse events to control the camera.
  42876. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42878. */
  42879. constructor(touchEnabled?: boolean);
  42880. /**
  42881. * Attach the mouse control to the HTML DOM element.
  42882. * @param element Defines the element that listens to the input events.
  42883. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42884. */
  42885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42886. /**
  42887. * Detach the current controls from the specified dom element.
  42888. * @param element Defines the element to stop listening the inputs from
  42889. */
  42890. detachControl(element: Nullable<HTMLElement>): void;
  42891. /**
  42892. * Gets the class name of the current input.
  42893. * @returns the class name.
  42894. */
  42895. getClassName(): string;
  42896. /**
  42897. * Get the friendly name associated with the input class.
  42898. * @returns the input's friendly name.
  42899. */
  42900. getSimpleName(): string;
  42901. private _pointerInput;
  42902. private _onMouseMove;
  42903. /**
  42904. * Rotate camera by mouse offset.
  42905. */
  42906. private rotateCamera;
  42907. }
  42908. }
  42909. declare module BABYLON {
  42910. /**
  42911. * Default Inputs manager for the FlyCamera.
  42912. * It groups all the default supported inputs for ease of use.
  42913. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42914. */
  42915. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  42916. /**
  42917. * Instantiates a new FlyCameraInputsManager.
  42918. * @param camera Defines the camera the inputs belong to.
  42919. */
  42920. constructor(camera: FlyCamera);
  42921. /**
  42922. * Add keyboard input support to the input manager.
  42923. * @returns the new FlyCameraKeyboardMoveInput().
  42924. */
  42925. addKeyboard(): FlyCameraInputsManager;
  42926. /**
  42927. * Add mouse input support to the input manager.
  42928. * @param touchEnabled Enable touch screen support.
  42929. * @returns the new FlyCameraMouseInput().
  42930. */
  42931. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  42932. }
  42933. }
  42934. declare module BABYLON {
  42935. /**
  42936. * This is a flying camera, designed for 3D movement and rotation in all directions,
  42937. * such as in a 3D Space Shooter or a Flight Simulator.
  42938. */
  42939. export class FlyCamera extends TargetCamera {
  42940. /**
  42941. * Define the collision ellipsoid of the camera.
  42942. * This is helpful for simulating a camera body, like a player's body.
  42943. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42944. */
  42945. ellipsoid: Vector3;
  42946. /**
  42947. * Define an offset for the position of the ellipsoid around the camera.
  42948. * This can be helpful if the camera is attached away from the player's body center,
  42949. * such as at its head.
  42950. */
  42951. ellipsoidOffset: Vector3;
  42952. /**
  42953. * Enable or disable collisions of the camera with the rest of the scene objects.
  42954. */
  42955. checkCollisions: boolean;
  42956. /**
  42957. * Enable or disable gravity on the camera.
  42958. */
  42959. applyGravity: boolean;
  42960. /**
  42961. * Define the current direction the camera is moving to.
  42962. */
  42963. cameraDirection: Vector3;
  42964. /**
  42965. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  42966. * This overrides and empties cameraRotation.
  42967. */
  42968. rotationQuaternion: Quaternion;
  42969. /**
  42970. * Track Roll to maintain the wanted Rolling when looking around.
  42971. */
  42972. _trackRoll: number;
  42973. /**
  42974. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  42975. */
  42976. rollCorrect: number;
  42977. /**
  42978. * Mimic a banked turn, Rolling the camera when Yawing.
  42979. * It's recommended to use rollCorrect = 10 for faster banking correction.
  42980. */
  42981. bankedTurn: boolean;
  42982. /**
  42983. * Limit in radians for how much Roll banking will add. (Default: 90°)
  42984. */
  42985. bankedTurnLimit: number;
  42986. /**
  42987. * Value of 0 disables the banked Roll.
  42988. * Value of 1 is equal to the Yaw angle in radians.
  42989. */
  42990. bankedTurnMultiplier: number;
  42991. /**
  42992. * The inputs manager loads all the input sources, such as keyboard and mouse.
  42993. */
  42994. inputs: FlyCameraInputsManager;
  42995. /**
  42996. * Gets the input sensibility for mouse input.
  42997. * Higher values reduce sensitivity.
  42998. */
  42999. get angularSensibility(): number;
  43000. /**
  43001. * Sets the input sensibility for a mouse input.
  43002. * Higher values reduce sensitivity.
  43003. */
  43004. set angularSensibility(value: number);
  43005. /**
  43006. * Get the keys for camera movement forward.
  43007. */
  43008. get keysForward(): number[];
  43009. /**
  43010. * Set the keys for camera movement forward.
  43011. */
  43012. set keysForward(value: number[]);
  43013. /**
  43014. * Get the keys for camera movement backward.
  43015. */
  43016. get keysBackward(): number[];
  43017. set keysBackward(value: number[]);
  43018. /**
  43019. * Get the keys for camera movement up.
  43020. */
  43021. get keysUp(): number[];
  43022. /**
  43023. * Set the keys for camera movement up.
  43024. */
  43025. set keysUp(value: number[]);
  43026. /**
  43027. * Get the keys for camera movement down.
  43028. */
  43029. get keysDown(): number[];
  43030. /**
  43031. * Set the keys for camera movement down.
  43032. */
  43033. set keysDown(value: number[]);
  43034. /**
  43035. * Get the keys for camera movement left.
  43036. */
  43037. get keysLeft(): number[];
  43038. /**
  43039. * Set the keys for camera movement left.
  43040. */
  43041. set keysLeft(value: number[]);
  43042. /**
  43043. * Set the keys for camera movement right.
  43044. */
  43045. get keysRight(): number[];
  43046. /**
  43047. * Set the keys for camera movement right.
  43048. */
  43049. set keysRight(value: number[]);
  43050. /**
  43051. * Event raised when the camera collides with a mesh in the scene.
  43052. */
  43053. onCollide: (collidedMesh: AbstractMesh) => void;
  43054. private _collider;
  43055. private _needMoveForGravity;
  43056. private _oldPosition;
  43057. private _diffPosition;
  43058. private _newPosition;
  43059. /** @hidden */
  43060. _localDirection: Vector3;
  43061. /** @hidden */
  43062. _transformedDirection: Vector3;
  43063. /**
  43064. * Instantiates a FlyCamera.
  43065. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43066. * such as in a 3D Space Shooter or a Flight Simulator.
  43067. * @param name Define the name of the camera in the scene.
  43068. * @param position Define the starting position of the camera in the scene.
  43069. * @param scene Define the scene the camera belongs to.
  43070. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43071. */
  43072. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43073. /**
  43074. * Attach a control to the HTML DOM element.
  43075. * @param element Defines the element that listens to the input events.
  43076. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43077. */
  43078. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43079. /**
  43080. * Detach a control from the HTML DOM element.
  43081. * The camera will stop reacting to that input.
  43082. * @param element Defines the element that listens to the input events.
  43083. */
  43084. detachControl(element: HTMLElement): void;
  43085. private _collisionMask;
  43086. /**
  43087. * Get the mask that the camera ignores in collision events.
  43088. */
  43089. get collisionMask(): number;
  43090. /**
  43091. * Set the mask that the camera ignores in collision events.
  43092. */
  43093. set collisionMask(mask: number);
  43094. /** @hidden */
  43095. _collideWithWorld(displacement: Vector3): void;
  43096. /** @hidden */
  43097. private _onCollisionPositionChange;
  43098. /** @hidden */
  43099. _checkInputs(): void;
  43100. /** @hidden */
  43101. _decideIfNeedsToMove(): boolean;
  43102. /** @hidden */
  43103. _updatePosition(): void;
  43104. /**
  43105. * Restore the Roll to its target value at the rate specified.
  43106. * @param rate - Higher means slower restoring.
  43107. * @hidden
  43108. */
  43109. restoreRoll(rate: number): void;
  43110. /**
  43111. * Destroy the camera and release the current resources held by it.
  43112. */
  43113. dispose(): void;
  43114. /**
  43115. * Get the current object class name.
  43116. * @returns the class name.
  43117. */
  43118. getClassName(): string;
  43119. }
  43120. }
  43121. declare module BABYLON {
  43122. /**
  43123. * Listen to keyboard events to control the camera.
  43124. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43125. */
  43126. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43127. /**
  43128. * Defines the camera the input is attached to.
  43129. */
  43130. camera: FlyCamera;
  43131. /**
  43132. * The list of keyboard keys used to control the forward move of the camera.
  43133. */
  43134. keysForward: number[];
  43135. /**
  43136. * The list of keyboard keys used to control the backward move of the camera.
  43137. */
  43138. keysBackward: number[];
  43139. /**
  43140. * The list of keyboard keys used to control the forward move of the camera.
  43141. */
  43142. keysUp: number[];
  43143. /**
  43144. * The list of keyboard keys used to control the backward move of the camera.
  43145. */
  43146. keysDown: number[];
  43147. /**
  43148. * The list of keyboard keys used to control the right strafe move of the camera.
  43149. */
  43150. keysRight: number[];
  43151. /**
  43152. * The list of keyboard keys used to control the left strafe move of the camera.
  43153. */
  43154. keysLeft: number[];
  43155. private _keys;
  43156. private _onCanvasBlurObserver;
  43157. private _onKeyboardObserver;
  43158. private _engine;
  43159. private _scene;
  43160. /**
  43161. * Attach the input controls to a specific dom element to get the input from.
  43162. * @param element Defines the element the controls should be listened from
  43163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43164. */
  43165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43166. /**
  43167. * Detach the current controls from the specified dom element.
  43168. * @param element Defines the element to stop listening the inputs from
  43169. */
  43170. detachControl(element: Nullable<HTMLElement>): void;
  43171. /**
  43172. * Gets the class name of the current intput.
  43173. * @returns the class name
  43174. */
  43175. getClassName(): string;
  43176. /** @hidden */
  43177. _onLostFocus(e: FocusEvent): void;
  43178. /**
  43179. * Get the friendly name associated with the input class.
  43180. * @returns the input friendly name
  43181. */
  43182. getSimpleName(): string;
  43183. /**
  43184. * Update the current camera state depending on the inputs that have been used this frame.
  43185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43186. */
  43187. checkInputs(): void;
  43188. }
  43189. }
  43190. declare module BABYLON {
  43191. /**
  43192. * Manage the mouse wheel inputs to control a follow camera.
  43193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43194. */
  43195. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43196. /**
  43197. * Defines the camera the input is attached to.
  43198. */
  43199. camera: FollowCamera;
  43200. /**
  43201. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43202. */
  43203. axisControlRadius: boolean;
  43204. /**
  43205. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43206. */
  43207. axisControlHeight: boolean;
  43208. /**
  43209. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43210. */
  43211. axisControlRotation: boolean;
  43212. /**
  43213. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43214. * relation to mouseWheel events.
  43215. */
  43216. wheelPrecision: number;
  43217. /**
  43218. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43219. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43220. */
  43221. wheelDeltaPercentage: number;
  43222. private _wheel;
  43223. private _observer;
  43224. /**
  43225. * Attach the input controls to a specific dom element to get the input from.
  43226. * @param element Defines the element the controls should be listened from
  43227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43228. */
  43229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43230. /**
  43231. * Detach the current controls from the specified dom element.
  43232. * @param element Defines the element to stop listening the inputs from
  43233. */
  43234. detachControl(element: Nullable<HTMLElement>): void;
  43235. /**
  43236. * Gets the class name of the current intput.
  43237. * @returns the class name
  43238. */
  43239. getClassName(): string;
  43240. /**
  43241. * Get the friendly name associated with the input class.
  43242. * @returns the input friendly name
  43243. */
  43244. getSimpleName(): string;
  43245. }
  43246. }
  43247. declare module BABYLON {
  43248. /**
  43249. * Manage the pointers inputs to control an follow camera.
  43250. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43251. */
  43252. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43253. /**
  43254. * Defines the camera the input is attached to.
  43255. */
  43256. camera: FollowCamera;
  43257. /**
  43258. * Gets the class name of the current input.
  43259. * @returns the class name
  43260. */
  43261. getClassName(): string;
  43262. /**
  43263. * Defines the pointer angular sensibility along the X axis or how fast is
  43264. * the camera rotating.
  43265. * A negative number will reverse the axis direction.
  43266. */
  43267. angularSensibilityX: number;
  43268. /**
  43269. * Defines the pointer angular sensibility along the Y axis or how fast is
  43270. * the camera rotating.
  43271. * A negative number will reverse the axis direction.
  43272. */
  43273. angularSensibilityY: number;
  43274. /**
  43275. * Defines the pointer pinch precision or how fast is the camera zooming.
  43276. * A negative number will reverse the axis direction.
  43277. */
  43278. pinchPrecision: number;
  43279. /**
  43280. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43281. * from 0.
  43282. * It defines the percentage of current camera.radius to use as delta when
  43283. * pinch zoom is used.
  43284. */
  43285. pinchDeltaPercentage: number;
  43286. /**
  43287. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43288. */
  43289. axisXControlRadius: boolean;
  43290. /**
  43291. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43292. */
  43293. axisXControlHeight: boolean;
  43294. /**
  43295. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43296. */
  43297. axisXControlRotation: boolean;
  43298. /**
  43299. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43300. */
  43301. axisYControlRadius: boolean;
  43302. /**
  43303. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43304. */
  43305. axisYControlHeight: boolean;
  43306. /**
  43307. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43308. */
  43309. axisYControlRotation: boolean;
  43310. /**
  43311. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43312. */
  43313. axisPinchControlRadius: boolean;
  43314. /**
  43315. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43316. */
  43317. axisPinchControlHeight: boolean;
  43318. /**
  43319. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43320. */
  43321. axisPinchControlRotation: boolean;
  43322. /**
  43323. * Log error messages if basic misconfiguration has occurred.
  43324. */
  43325. warningEnable: boolean;
  43326. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43327. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43328. private _warningCounter;
  43329. private _warning;
  43330. }
  43331. }
  43332. declare module BABYLON {
  43333. /**
  43334. * Default Inputs manager for the FollowCamera.
  43335. * It groups all the default supported inputs for ease of use.
  43336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43337. */
  43338. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43339. /**
  43340. * Instantiates a new FollowCameraInputsManager.
  43341. * @param camera Defines the camera the inputs belong to
  43342. */
  43343. constructor(camera: FollowCamera);
  43344. /**
  43345. * Add keyboard input support to the input manager.
  43346. * @returns the current input manager
  43347. */
  43348. addKeyboard(): FollowCameraInputsManager;
  43349. /**
  43350. * Add mouse wheel input support to the input manager.
  43351. * @returns the current input manager
  43352. */
  43353. addMouseWheel(): FollowCameraInputsManager;
  43354. /**
  43355. * Add pointers input support to the input manager.
  43356. * @returns the current input manager
  43357. */
  43358. addPointers(): FollowCameraInputsManager;
  43359. /**
  43360. * Add orientation input support to the input manager.
  43361. * @returns the current input manager
  43362. */
  43363. addVRDeviceOrientation(): FollowCameraInputsManager;
  43364. }
  43365. }
  43366. declare module BABYLON {
  43367. /**
  43368. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43369. * an arc rotate version arcFollowCamera are available.
  43370. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43371. */
  43372. export class FollowCamera extends TargetCamera {
  43373. /**
  43374. * Distance the follow camera should follow an object at
  43375. */
  43376. radius: number;
  43377. /**
  43378. * Minimum allowed distance of the camera to the axis of rotation
  43379. * (The camera can not get closer).
  43380. * This can help limiting how the Camera is able to move in the scene.
  43381. */
  43382. lowerRadiusLimit: Nullable<number>;
  43383. /**
  43384. * Maximum allowed distance of the camera to the axis of rotation
  43385. * (The camera can not get further).
  43386. * This can help limiting how the Camera is able to move in the scene.
  43387. */
  43388. upperRadiusLimit: Nullable<number>;
  43389. /**
  43390. * Define a rotation offset between the camera and the object it follows
  43391. */
  43392. rotationOffset: number;
  43393. /**
  43394. * Minimum allowed angle to camera position relative to target object.
  43395. * This can help limiting how the Camera is able to move in the scene.
  43396. */
  43397. lowerRotationOffsetLimit: Nullable<number>;
  43398. /**
  43399. * Maximum allowed angle to camera position relative to target object.
  43400. * This can help limiting how the Camera is able to move in the scene.
  43401. */
  43402. upperRotationOffsetLimit: Nullable<number>;
  43403. /**
  43404. * Define a height offset between the camera and the object it follows.
  43405. * It can help following an object from the top (like a car chaing a plane)
  43406. */
  43407. heightOffset: number;
  43408. /**
  43409. * Minimum allowed height of camera position relative to target object.
  43410. * This can help limiting how the Camera is able to move in the scene.
  43411. */
  43412. lowerHeightOffsetLimit: Nullable<number>;
  43413. /**
  43414. * Maximum allowed height of camera position relative to target object.
  43415. * This can help limiting how the Camera is able to move in the scene.
  43416. */
  43417. upperHeightOffsetLimit: Nullable<number>;
  43418. /**
  43419. * Define how fast the camera can accelerate to follow it s target.
  43420. */
  43421. cameraAcceleration: number;
  43422. /**
  43423. * Define the speed limit of the camera following an object.
  43424. */
  43425. maxCameraSpeed: number;
  43426. /**
  43427. * Define the target of the camera.
  43428. */
  43429. lockedTarget: Nullable<AbstractMesh>;
  43430. /**
  43431. * Defines the input associated with the camera.
  43432. */
  43433. inputs: FollowCameraInputsManager;
  43434. /**
  43435. * Instantiates the follow camera.
  43436. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43437. * @param name Define the name of the camera in the scene
  43438. * @param position Define the position of the camera
  43439. * @param scene Define the scene the camera belong to
  43440. * @param lockedTarget Define the target of the camera
  43441. */
  43442. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43443. private _follow;
  43444. /**
  43445. * Attached controls to the current camera.
  43446. * @param element Defines the element the controls should be listened from
  43447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43448. */
  43449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43450. /**
  43451. * Detach the current controls from the camera.
  43452. * The camera will stop reacting to inputs.
  43453. * @param element Defines the element to stop listening the inputs from
  43454. */
  43455. detachControl(element: HTMLElement): void;
  43456. /** @hidden */
  43457. _checkInputs(): void;
  43458. private _checkLimits;
  43459. /**
  43460. * Gets the camera class name.
  43461. * @returns the class name
  43462. */
  43463. getClassName(): string;
  43464. }
  43465. /**
  43466. * Arc Rotate version of the follow camera.
  43467. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43468. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43469. */
  43470. export class ArcFollowCamera extends TargetCamera {
  43471. /** The longitudinal angle of the camera */
  43472. alpha: number;
  43473. /** The latitudinal angle of the camera */
  43474. beta: number;
  43475. /** The radius of the camera from its target */
  43476. radius: number;
  43477. /** Define the camera target (the messh it should follow) */
  43478. target: Nullable<AbstractMesh>;
  43479. private _cartesianCoordinates;
  43480. /**
  43481. * Instantiates a new ArcFollowCamera
  43482. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43483. * @param name Define the name of the camera
  43484. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43485. * @param beta Define the rotation angle of the camera around the elevation axis
  43486. * @param radius Define the radius of the camera from its target point
  43487. * @param target Define the target of the camera
  43488. * @param scene Define the scene the camera belongs to
  43489. */
  43490. constructor(name: string,
  43491. /** The longitudinal angle of the camera */
  43492. alpha: number,
  43493. /** The latitudinal angle of the camera */
  43494. beta: number,
  43495. /** The radius of the camera from its target */
  43496. radius: number,
  43497. /** Define the camera target (the messh it should follow) */
  43498. target: Nullable<AbstractMesh>, scene: Scene);
  43499. private _follow;
  43500. /** @hidden */
  43501. _checkInputs(): void;
  43502. /**
  43503. * Returns the class name of the object.
  43504. * It is mostly used internally for serialization purposes.
  43505. */
  43506. getClassName(): string;
  43507. }
  43508. }
  43509. declare module BABYLON {
  43510. /**
  43511. * Manage the keyboard inputs to control the movement of a follow camera.
  43512. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43513. */
  43514. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43515. /**
  43516. * Defines the camera the input is attached to.
  43517. */
  43518. camera: FollowCamera;
  43519. /**
  43520. * Defines the list of key codes associated with the up action (increase heightOffset)
  43521. */
  43522. keysHeightOffsetIncr: number[];
  43523. /**
  43524. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43525. */
  43526. keysHeightOffsetDecr: number[];
  43527. /**
  43528. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43529. */
  43530. keysHeightOffsetModifierAlt: boolean;
  43531. /**
  43532. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43533. */
  43534. keysHeightOffsetModifierCtrl: boolean;
  43535. /**
  43536. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43537. */
  43538. keysHeightOffsetModifierShift: boolean;
  43539. /**
  43540. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43541. */
  43542. keysRotationOffsetIncr: number[];
  43543. /**
  43544. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43545. */
  43546. keysRotationOffsetDecr: number[];
  43547. /**
  43548. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43549. */
  43550. keysRotationOffsetModifierAlt: boolean;
  43551. /**
  43552. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43553. */
  43554. keysRotationOffsetModifierCtrl: boolean;
  43555. /**
  43556. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43557. */
  43558. keysRotationOffsetModifierShift: boolean;
  43559. /**
  43560. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43561. */
  43562. keysRadiusIncr: number[];
  43563. /**
  43564. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43565. */
  43566. keysRadiusDecr: number[];
  43567. /**
  43568. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43569. */
  43570. keysRadiusModifierAlt: boolean;
  43571. /**
  43572. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43573. */
  43574. keysRadiusModifierCtrl: boolean;
  43575. /**
  43576. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43577. */
  43578. keysRadiusModifierShift: boolean;
  43579. /**
  43580. * Defines the rate of change of heightOffset.
  43581. */
  43582. heightSensibility: number;
  43583. /**
  43584. * Defines the rate of change of rotationOffset.
  43585. */
  43586. rotationSensibility: number;
  43587. /**
  43588. * Defines the rate of change of radius.
  43589. */
  43590. radiusSensibility: number;
  43591. private _keys;
  43592. private _ctrlPressed;
  43593. private _altPressed;
  43594. private _shiftPressed;
  43595. private _onCanvasBlurObserver;
  43596. private _onKeyboardObserver;
  43597. private _engine;
  43598. private _scene;
  43599. /**
  43600. * Attach the input controls to a specific dom element to get the input from.
  43601. * @param element Defines the element the controls should be listened from
  43602. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43603. */
  43604. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43605. /**
  43606. * Detach the current controls from the specified dom element.
  43607. * @param element Defines the element to stop listening the inputs from
  43608. */
  43609. detachControl(element: Nullable<HTMLElement>): void;
  43610. /**
  43611. * Update the current camera state depending on the inputs that have been used this frame.
  43612. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43613. */
  43614. checkInputs(): void;
  43615. /**
  43616. * Gets the class name of the current input.
  43617. * @returns the class name
  43618. */
  43619. getClassName(): string;
  43620. /**
  43621. * Get the friendly name associated with the input class.
  43622. * @returns the input friendly name
  43623. */
  43624. getSimpleName(): string;
  43625. /**
  43626. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43627. * allow modification of the heightOffset value.
  43628. */
  43629. private _modifierHeightOffset;
  43630. /**
  43631. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43632. * allow modification of the rotationOffset value.
  43633. */
  43634. private _modifierRotationOffset;
  43635. /**
  43636. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43637. * allow modification of the radius value.
  43638. */
  43639. private _modifierRadius;
  43640. }
  43641. }
  43642. declare module BABYLON {
  43643. interface FreeCameraInputsManager {
  43644. /**
  43645. * @hidden
  43646. */
  43647. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43648. /**
  43649. * Add orientation input support to the input manager.
  43650. * @returns the current input manager
  43651. */
  43652. addDeviceOrientation(): FreeCameraInputsManager;
  43653. }
  43654. /**
  43655. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43656. * Screen rotation is taken into account.
  43657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43658. */
  43659. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43660. private _camera;
  43661. private _screenOrientationAngle;
  43662. private _constantTranform;
  43663. private _screenQuaternion;
  43664. private _alpha;
  43665. private _beta;
  43666. private _gamma;
  43667. /**
  43668. * Can be used to detect if a device orientation sensor is available on a device
  43669. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43670. * @returns a promise that will resolve on orientation change
  43671. */
  43672. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43673. /**
  43674. * @hidden
  43675. */
  43676. _onDeviceOrientationChangedObservable: Observable<void>;
  43677. /**
  43678. * Instantiates a new input
  43679. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43680. */
  43681. constructor();
  43682. /**
  43683. * Define the camera controlled by the input.
  43684. */
  43685. get camera(): FreeCamera;
  43686. set camera(camera: FreeCamera);
  43687. /**
  43688. * Attach the input controls to a specific dom element to get the input from.
  43689. * @param element Defines the element the controls should be listened from
  43690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43691. */
  43692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43693. private _orientationChanged;
  43694. private _deviceOrientation;
  43695. /**
  43696. * Detach the current controls from the specified dom element.
  43697. * @param element Defines the element to stop listening the inputs from
  43698. */
  43699. detachControl(element: Nullable<HTMLElement>): void;
  43700. /**
  43701. * Update the current camera state depending on the inputs that have been used this frame.
  43702. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43703. */
  43704. checkInputs(): void;
  43705. /**
  43706. * Gets the class name of the current intput.
  43707. * @returns the class name
  43708. */
  43709. getClassName(): string;
  43710. /**
  43711. * Get the friendly name associated with the input class.
  43712. * @returns the input friendly name
  43713. */
  43714. getSimpleName(): string;
  43715. }
  43716. }
  43717. declare module BABYLON {
  43718. /**
  43719. * Manage the gamepad inputs to control a free camera.
  43720. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43721. */
  43722. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43723. /**
  43724. * Define the camera the input is attached to.
  43725. */
  43726. camera: FreeCamera;
  43727. /**
  43728. * Define the Gamepad controlling the input
  43729. */
  43730. gamepad: Nullable<Gamepad>;
  43731. /**
  43732. * Defines the gamepad rotation sensiblity.
  43733. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43734. */
  43735. gamepadAngularSensibility: number;
  43736. /**
  43737. * Defines the gamepad move sensiblity.
  43738. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43739. */
  43740. gamepadMoveSensibility: number;
  43741. private _yAxisScale;
  43742. /**
  43743. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43744. */
  43745. get invertYAxis(): boolean;
  43746. set invertYAxis(value: boolean);
  43747. private _onGamepadConnectedObserver;
  43748. private _onGamepadDisconnectedObserver;
  43749. private _cameraTransform;
  43750. private _deltaTransform;
  43751. private _vector3;
  43752. private _vector2;
  43753. /**
  43754. * Attach the input controls to a specific dom element to get the input from.
  43755. * @param element Defines the element the controls should be listened from
  43756. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43757. */
  43758. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43759. /**
  43760. * Detach the current controls from the specified dom element.
  43761. * @param element Defines the element to stop listening the inputs from
  43762. */
  43763. detachControl(element: Nullable<HTMLElement>): void;
  43764. /**
  43765. * Update the current camera state depending on the inputs that have been used this frame.
  43766. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43767. */
  43768. checkInputs(): void;
  43769. /**
  43770. * Gets the class name of the current intput.
  43771. * @returns the class name
  43772. */
  43773. getClassName(): string;
  43774. /**
  43775. * Get the friendly name associated with the input class.
  43776. * @returns the input friendly name
  43777. */
  43778. getSimpleName(): string;
  43779. }
  43780. }
  43781. declare module BABYLON {
  43782. /**
  43783. * Defines the potential axis of a Joystick
  43784. */
  43785. export enum JoystickAxis {
  43786. /** X axis */
  43787. X = 0,
  43788. /** Y axis */
  43789. Y = 1,
  43790. /** Z axis */
  43791. Z = 2
  43792. }
  43793. /**
  43794. * Class used to define virtual joystick (used in touch mode)
  43795. */
  43796. export class VirtualJoystick {
  43797. /**
  43798. * Gets or sets a boolean indicating that left and right values must be inverted
  43799. */
  43800. reverseLeftRight: boolean;
  43801. /**
  43802. * Gets or sets a boolean indicating that up and down values must be inverted
  43803. */
  43804. reverseUpDown: boolean;
  43805. /**
  43806. * Gets the offset value for the position (ie. the change of the position value)
  43807. */
  43808. deltaPosition: Vector3;
  43809. /**
  43810. * Gets a boolean indicating if the virtual joystick was pressed
  43811. */
  43812. pressed: boolean;
  43813. /**
  43814. * Canvas the virtual joystick will render onto, default z-index of this is 5
  43815. */
  43816. static Canvas: Nullable<HTMLCanvasElement>;
  43817. private static _globalJoystickIndex;
  43818. private static vjCanvasContext;
  43819. private static vjCanvasWidth;
  43820. private static vjCanvasHeight;
  43821. private static halfWidth;
  43822. private _action;
  43823. private _axisTargetedByLeftAndRight;
  43824. private _axisTargetedByUpAndDown;
  43825. private _joystickSensibility;
  43826. private _inversedSensibility;
  43827. private _joystickPointerID;
  43828. private _joystickColor;
  43829. private _joystickPointerPos;
  43830. private _joystickPreviousPointerPos;
  43831. private _joystickPointerStartPos;
  43832. private _deltaJoystickVector;
  43833. private _leftJoystick;
  43834. private _touches;
  43835. private _onPointerDownHandlerRef;
  43836. private _onPointerMoveHandlerRef;
  43837. private _onPointerUpHandlerRef;
  43838. private _onResize;
  43839. /**
  43840. * Creates a new virtual joystick
  43841. * @param leftJoystick defines that the joystick is for left hand (false by default)
  43842. */
  43843. constructor(leftJoystick?: boolean);
  43844. /**
  43845. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  43846. * @param newJoystickSensibility defines the new sensibility
  43847. */
  43848. setJoystickSensibility(newJoystickSensibility: number): void;
  43849. private _onPointerDown;
  43850. private _onPointerMove;
  43851. private _onPointerUp;
  43852. /**
  43853. * Change the color of the virtual joystick
  43854. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  43855. */
  43856. setJoystickColor(newColor: string): void;
  43857. /**
  43858. * Defines a callback to call when the joystick is touched
  43859. * @param action defines the callback
  43860. */
  43861. setActionOnTouch(action: () => any): void;
  43862. /**
  43863. * Defines which axis you'd like to control for left & right
  43864. * @param axis defines the axis to use
  43865. */
  43866. setAxisForLeftRight(axis: JoystickAxis): void;
  43867. /**
  43868. * Defines which axis you'd like to control for up & down
  43869. * @param axis defines the axis to use
  43870. */
  43871. setAxisForUpDown(axis: JoystickAxis): void;
  43872. private _drawVirtualJoystick;
  43873. /**
  43874. * Release internal HTML canvas
  43875. */
  43876. releaseCanvas(): void;
  43877. }
  43878. }
  43879. declare module BABYLON {
  43880. interface FreeCameraInputsManager {
  43881. /**
  43882. * Add virtual joystick input support to the input manager.
  43883. * @returns the current input manager
  43884. */
  43885. addVirtualJoystick(): FreeCameraInputsManager;
  43886. }
  43887. /**
  43888. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  43889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43890. */
  43891. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  43892. /**
  43893. * Defines the camera the input is attached to.
  43894. */
  43895. camera: FreeCamera;
  43896. private _leftjoystick;
  43897. private _rightjoystick;
  43898. /**
  43899. * Gets the left stick of the virtual joystick.
  43900. * @returns The virtual Joystick
  43901. */
  43902. getLeftJoystick(): VirtualJoystick;
  43903. /**
  43904. * Gets the right stick of the virtual joystick.
  43905. * @returns The virtual Joystick
  43906. */
  43907. getRightJoystick(): VirtualJoystick;
  43908. /**
  43909. * Update the current camera state depending on the inputs that have been used this frame.
  43910. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43911. */
  43912. checkInputs(): void;
  43913. /**
  43914. * Attach the input controls to a specific dom element to get the input from.
  43915. * @param element Defines the element the controls should be listened from
  43916. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43917. */
  43918. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43919. /**
  43920. * Detach the current controls from the specified dom element.
  43921. * @param element Defines the element to stop listening the inputs from
  43922. */
  43923. detachControl(element: Nullable<HTMLElement>): void;
  43924. /**
  43925. * Gets the class name of the current intput.
  43926. * @returns the class name
  43927. */
  43928. getClassName(): string;
  43929. /**
  43930. * Get the friendly name associated with the input class.
  43931. * @returns the input friendly name
  43932. */
  43933. getSimpleName(): string;
  43934. }
  43935. }
  43936. declare module BABYLON {
  43937. /**
  43938. * This represents a FPS type of camera controlled by touch.
  43939. * This is like a universal camera minus the Gamepad controls.
  43940. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43941. */
  43942. export class TouchCamera extends FreeCamera {
  43943. /**
  43944. * Defines the touch sensibility for rotation.
  43945. * The higher the faster.
  43946. */
  43947. get touchAngularSensibility(): number;
  43948. set touchAngularSensibility(value: number);
  43949. /**
  43950. * Defines the touch sensibility for move.
  43951. * The higher the faster.
  43952. */
  43953. get touchMoveSensibility(): number;
  43954. set touchMoveSensibility(value: number);
  43955. /**
  43956. * Instantiates a new touch camera.
  43957. * This represents a FPS type of camera controlled by touch.
  43958. * This is like a universal camera minus the Gamepad controls.
  43959. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43960. * @param name Define the name of the camera in the scene
  43961. * @param position Define the start position of the camera in the scene
  43962. * @param scene Define the scene the camera belongs to
  43963. */
  43964. constructor(name: string, position: Vector3, scene: Scene);
  43965. /**
  43966. * Gets the current object class name.
  43967. * @return the class name
  43968. */
  43969. getClassName(): string;
  43970. /** @hidden */
  43971. _setupInputs(): void;
  43972. }
  43973. }
  43974. declare module BABYLON {
  43975. /**
  43976. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  43977. * being tilted forward or back and left or right.
  43978. */
  43979. export class DeviceOrientationCamera extends FreeCamera {
  43980. private _initialQuaternion;
  43981. private _quaternionCache;
  43982. private _tmpDragQuaternion;
  43983. private _disablePointerInputWhenUsingDeviceOrientation;
  43984. /**
  43985. * Creates a new device orientation camera
  43986. * @param name The name of the camera
  43987. * @param position The start position camera
  43988. * @param scene The scene the camera belongs to
  43989. */
  43990. constructor(name: string, position: Vector3, scene: Scene);
  43991. /**
  43992. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  43993. */
  43994. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  43995. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  43996. private _dragFactor;
  43997. /**
  43998. * Enabled turning on the y axis when the orientation sensor is active
  43999. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44000. */
  44001. enableHorizontalDragging(dragFactor?: number): void;
  44002. /**
  44003. * Gets the current instance class name ("DeviceOrientationCamera").
  44004. * This helps avoiding instanceof at run time.
  44005. * @returns the class name
  44006. */
  44007. getClassName(): string;
  44008. /**
  44009. * @hidden
  44010. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44011. */
  44012. _checkInputs(): void;
  44013. /**
  44014. * Reset the camera to its default orientation on the specified axis only.
  44015. * @param axis The axis to reset
  44016. */
  44017. resetToCurrentRotation(axis?: Axis): void;
  44018. }
  44019. }
  44020. declare module BABYLON {
  44021. /**
  44022. * Defines supported buttons for XBox360 compatible gamepads
  44023. */
  44024. export enum Xbox360Button {
  44025. /** A */
  44026. A = 0,
  44027. /** B */
  44028. B = 1,
  44029. /** X */
  44030. X = 2,
  44031. /** Y */
  44032. Y = 3,
  44033. /** Left button */
  44034. LB = 4,
  44035. /** Right button */
  44036. RB = 5,
  44037. /** Back */
  44038. Back = 8,
  44039. /** Start */
  44040. Start = 9,
  44041. /** Left stick */
  44042. LeftStick = 10,
  44043. /** Right stick */
  44044. RightStick = 11
  44045. }
  44046. /** Defines values for XBox360 DPad */
  44047. export enum Xbox360Dpad {
  44048. /** Up */
  44049. Up = 12,
  44050. /** Down */
  44051. Down = 13,
  44052. /** Left */
  44053. Left = 14,
  44054. /** Right */
  44055. Right = 15
  44056. }
  44057. /**
  44058. * Defines a XBox360 gamepad
  44059. */
  44060. export class Xbox360Pad extends Gamepad {
  44061. private _leftTrigger;
  44062. private _rightTrigger;
  44063. private _onlefttriggerchanged;
  44064. private _onrighttriggerchanged;
  44065. private _onbuttondown;
  44066. private _onbuttonup;
  44067. private _ondpaddown;
  44068. private _ondpadup;
  44069. /** Observable raised when a button is pressed */
  44070. onButtonDownObservable: Observable<Xbox360Button>;
  44071. /** Observable raised when a button is released */
  44072. onButtonUpObservable: Observable<Xbox360Button>;
  44073. /** Observable raised when a pad is pressed */
  44074. onPadDownObservable: Observable<Xbox360Dpad>;
  44075. /** Observable raised when a pad is released */
  44076. onPadUpObservable: Observable<Xbox360Dpad>;
  44077. private _buttonA;
  44078. private _buttonB;
  44079. private _buttonX;
  44080. private _buttonY;
  44081. private _buttonBack;
  44082. private _buttonStart;
  44083. private _buttonLB;
  44084. private _buttonRB;
  44085. private _buttonLeftStick;
  44086. private _buttonRightStick;
  44087. private _dPadUp;
  44088. private _dPadDown;
  44089. private _dPadLeft;
  44090. private _dPadRight;
  44091. private _isXboxOnePad;
  44092. /**
  44093. * Creates a new XBox360 gamepad object
  44094. * @param id defines the id of this gamepad
  44095. * @param index defines its index
  44096. * @param gamepad defines the internal HTML gamepad object
  44097. * @param xboxOne defines if it is a XBox One gamepad
  44098. */
  44099. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44100. /**
  44101. * Defines the callback to call when left trigger is pressed
  44102. * @param callback defines the callback to use
  44103. */
  44104. onlefttriggerchanged(callback: (value: number) => void): void;
  44105. /**
  44106. * Defines the callback to call when right trigger is pressed
  44107. * @param callback defines the callback to use
  44108. */
  44109. onrighttriggerchanged(callback: (value: number) => void): void;
  44110. /**
  44111. * Gets the left trigger value
  44112. */
  44113. get leftTrigger(): number;
  44114. /**
  44115. * Sets the left trigger value
  44116. */
  44117. set leftTrigger(newValue: number);
  44118. /**
  44119. * Gets the right trigger value
  44120. */
  44121. get rightTrigger(): number;
  44122. /**
  44123. * Sets the right trigger value
  44124. */
  44125. set rightTrigger(newValue: number);
  44126. /**
  44127. * Defines the callback to call when a button is pressed
  44128. * @param callback defines the callback to use
  44129. */
  44130. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44131. /**
  44132. * Defines the callback to call when a button is released
  44133. * @param callback defines the callback to use
  44134. */
  44135. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44136. /**
  44137. * Defines the callback to call when a pad is pressed
  44138. * @param callback defines the callback to use
  44139. */
  44140. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44141. /**
  44142. * Defines the callback to call when a pad is released
  44143. * @param callback defines the callback to use
  44144. */
  44145. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44146. private _setButtonValue;
  44147. private _setDPadValue;
  44148. /**
  44149. * Gets the value of the `A` button
  44150. */
  44151. get buttonA(): number;
  44152. /**
  44153. * Sets the value of the `A` button
  44154. */
  44155. set buttonA(value: number);
  44156. /**
  44157. * Gets the value of the `B` button
  44158. */
  44159. get buttonB(): number;
  44160. /**
  44161. * Sets the value of the `B` button
  44162. */
  44163. set buttonB(value: number);
  44164. /**
  44165. * Gets the value of the `X` button
  44166. */
  44167. get buttonX(): number;
  44168. /**
  44169. * Sets the value of the `X` button
  44170. */
  44171. set buttonX(value: number);
  44172. /**
  44173. * Gets the value of the `Y` button
  44174. */
  44175. get buttonY(): number;
  44176. /**
  44177. * Sets the value of the `Y` button
  44178. */
  44179. set buttonY(value: number);
  44180. /**
  44181. * Gets the value of the `Start` button
  44182. */
  44183. get buttonStart(): number;
  44184. /**
  44185. * Sets the value of the `Start` button
  44186. */
  44187. set buttonStart(value: number);
  44188. /**
  44189. * Gets the value of the `Back` button
  44190. */
  44191. get buttonBack(): number;
  44192. /**
  44193. * Sets the value of the `Back` button
  44194. */
  44195. set buttonBack(value: number);
  44196. /**
  44197. * Gets the value of the `Left` button
  44198. */
  44199. get buttonLB(): number;
  44200. /**
  44201. * Sets the value of the `Left` button
  44202. */
  44203. set buttonLB(value: number);
  44204. /**
  44205. * Gets the value of the `Right` button
  44206. */
  44207. get buttonRB(): number;
  44208. /**
  44209. * Sets the value of the `Right` button
  44210. */
  44211. set buttonRB(value: number);
  44212. /**
  44213. * Gets the value of the Left joystick
  44214. */
  44215. get buttonLeftStick(): number;
  44216. /**
  44217. * Sets the value of the Left joystick
  44218. */
  44219. set buttonLeftStick(value: number);
  44220. /**
  44221. * Gets the value of the Right joystick
  44222. */
  44223. get buttonRightStick(): number;
  44224. /**
  44225. * Sets the value of the Right joystick
  44226. */
  44227. set buttonRightStick(value: number);
  44228. /**
  44229. * Gets the value of D-pad up
  44230. */
  44231. get dPadUp(): number;
  44232. /**
  44233. * Sets the value of D-pad up
  44234. */
  44235. set dPadUp(value: number);
  44236. /**
  44237. * Gets the value of D-pad down
  44238. */
  44239. get dPadDown(): number;
  44240. /**
  44241. * Sets the value of D-pad down
  44242. */
  44243. set dPadDown(value: number);
  44244. /**
  44245. * Gets the value of D-pad left
  44246. */
  44247. get dPadLeft(): number;
  44248. /**
  44249. * Sets the value of D-pad left
  44250. */
  44251. set dPadLeft(value: number);
  44252. /**
  44253. * Gets the value of D-pad right
  44254. */
  44255. get dPadRight(): number;
  44256. /**
  44257. * Sets the value of D-pad right
  44258. */
  44259. set dPadRight(value: number);
  44260. /**
  44261. * Force the gamepad to synchronize with device values
  44262. */
  44263. update(): void;
  44264. /**
  44265. * Disposes the gamepad
  44266. */
  44267. dispose(): void;
  44268. }
  44269. }
  44270. declare module BABYLON {
  44271. /**
  44272. * Defines supported buttons for DualShock compatible gamepads
  44273. */
  44274. export enum DualShockButton {
  44275. /** Cross */
  44276. Cross = 0,
  44277. /** Circle */
  44278. Circle = 1,
  44279. /** Square */
  44280. Square = 2,
  44281. /** Triangle */
  44282. Triangle = 3,
  44283. /** L1 */
  44284. L1 = 4,
  44285. /** R1 */
  44286. R1 = 5,
  44287. /** Share */
  44288. Share = 8,
  44289. /** Options */
  44290. Options = 9,
  44291. /** Left stick */
  44292. LeftStick = 10,
  44293. /** Right stick */
  44294. RightStick = 11
  44295. }
  44296. /** Defines values for DualShock DPad */
  44297. export enum DualShockDpad {
  44298. /** Up */
  44299. Up = 12,
  44300. /** Down */
  44301. Down = 13,
  44302. /** Left */
  44303. Left = 14,
  44304. /** Right */
  44305. Right = 15
  44306. }
  44307. /**
  44308. * Defines a DualShock gamepad
  44309. */
  44310. export class DualShockPad extends Gamepad {
  44311. private _leftTrigger;
  44312. private _rightTrigger;
  44313. private _onlefttriggerchanged;
  44314. private _onrighttriggerchanged;
  44315. private _onbuttondown;
  44316. private _onbuttonup;
  44317. private _ondpaddown;
  44318. private _ondpadup;
  44319. /** Observable raised when a button is pressed */
  44320. onButtonDownObservable: Observable<DualShockButton>;
  44321. /** Observable raised when a button is released */
  44322. onButtonUpObservable: Observable<DualShockButton>;
  44323. /** Observable raised when a pad is pressed */
  44324. onPadDownObservable: Observable<DualShockDpad>;
  44325. /** Observable raised when a pad is released */
  44326. onPadUpObservable: Observable<DualShockDpad>;
  44327. private _buttonCross;
  44328. private _buttonCircle;
  44329. private _buttonSquare;
  44330. private _buttonTriangle;
  44331. private _buttonShare;
  44332. private _buttonOptions;
  44333. private _buttonL1;
  44334. private _buttonR1;
  44335. private _buttonLeftStick;
  44336. private _buttonRightStick;
  44337. private _dPadUp;
  44338. private _dPadDown;
  44339. private _dPadLeft;
  44340. private _dPadRight;
  44341. /**
  44342. * Creates a new DualShock gamepad object
  44343. * @param id defines the id of this gamepad
  44344. * @param index defines its index
  44345. * @param gamepad defines the internal HTML gamepad object
  44346. */
  44347. constructor(id: string, index: number, gamepad: any);
  44348. /**
  44349. * Defines the callback to call when left trigger is pressed
  44350. * @param callback defines the callback to use
  44351. */
  44352. onlefttriggerchanged(callback: (value: number) => void): void;
  44353. /**
  44354. * Defines the callback to call when right trigger is pressed
  44355. * @param callback defines the callback to use
  44356. */
  44357. onrighttriggerchanged(callback: (value: number) => void): void;
  44358. /**
  44359. * Gets the left trigger value
  44360. */
  44361. get leftTrigger(): number;
  44362. /**
  44363. * Sets the left trigger value
  44364. */
  44365. set leftTrigger(newValue: number);
  44366. /**
  44367. * Gets the right trigger value
  44368. */
  44369. get rightTrigger(): number;
  44370. /**
  44371. * Sets the right trigger value
  44372. */
  44373. set rightTrigger(newValue: number);
  44374. /**
  44375. * Defines the callback to call when a button is pressed
  44376. * @param callback defines the callback to use
  44377. */
  44378. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44379. /**
  44380. * Defines the callback to call when a button is released
  44381. * @param callback defines the callback to use
  44382. */
  44383. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44384. /**
  44385. * Defines the callback to call when a pad is pressed
  44386. * @param callback defines the callback to use
  44387. */
  44388. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44389. /**
  44390. * Defines the callback to call when a pad is released
  44391. * @param callback defines the callback to use
  44392. */
  44393. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44394. private _setButtonValue;
  44395. private _setDPadValue;
  44396. /**
  44397. * Gets the value of the `Cross` button
  44398. */
  44399. get buttonCross(): number;
  44400. /**
  44401. * Sets the value of the `Cross` button
  44402. */
  44403. set buttonCross(value: number);
  44404. /**
  44405. * Gets the value of the `Circle` button
  44406. */
  44407. get buttonCircle(): number;
  44408. /**
  44409. * Sets the value of the `Circle` button
  44410. */
  44411. set buttonCircle(value: number);
  44412. /**
  44413. * Gets the value of the `Square` button
  44414. */
  44415. get buttonSquare(): number;
  44416. /**
  44417. * Sets the value of the `Square` button
  44418. */
  44419. set buttonSquare(value: number);
  44420. /**
  44421. * Gets the value of the `Triangle` button
  44422. */
  44423. get buttonTriangle(): number;
  44424. /**
  44425. * Sets the value of the `Triangle` button
  44426. */
  44427. set buttonTriangle(value: number);
  44428. /**
  44429. * Gets the value of the `Options` button
  44430. */
  44431. get buttonOptions(): number;
  44432. /**
  44433. * Sets the value of the `Options` button
  44434. */
  44435. set buttonOptions(value: number);
  44436. /**
  44437. * Gets the value of the `Share` button
  44438. */
  44439. get buttonShare(): number;
  44440. /**
  44441. * Sets the value of the `Share` button
  44442. */
  44443. set buttonShare(value: number);
  44444. /**
  44445. * Gets the value of the `L1` button
  44446. */
  44447. get buttonL1(): number;
  44448. /**
  44449. * Sets the value of the `L1` button
  44450. */
  44451. set buttonL1(value: number);
  44452. /**
  44453. * Gets the value of the `R1` button
  44454. */
  44455. get buttonR1(): number;
  44456. /**
  44457. * Sets the value of the `R1` button
  44458. */
  44459. set buttonR1(value: number);
  44460. /**
  44461. * Gets the value of the Left joystick
  44462. */
  44463. get buttonLeftStick(): number;
  44464. /**
  44465. * Sets the value of the Left joystick
  44466. */
  44467. set buttonLeftStick(value: number);
  44468. /**
  44469. * Gets the value of the Right joystick
  44470. */
  44471. get buttonRightStick(): number;
  44472. /**
  44473. * Sets the value of the Right joystick
  44474. */
  44475. set buttonRightStick(value: number);
  44476. /**
  44477. * Gets the value of D-pad up
  44478. */
  44479. get dPadUp(): number;
  44480. /**
  44481. * Sets the value of D-pad up
  44482. */
  44483. set dPadUp(value: number);
  44484. /**
  44485. * Gets the value of D-pad down
  44486. */
  44487. get dPadDown(): number;
  44488. /**
  44489. * Sets the value of D-pad down
  44490. */
  44491. set dPadDown(value: number);
  44492. /**
  44493. * Gets the value of D-pad left
  44494. */
  44495. get dPadLeft(): number;
  44496. /**
  44497. * Sets the value of D-pad left
  44498. */
  44499. set dPadLeft(value: number);
  44500. /**
  44501. * Gets the value of D-pad right
  44502. */
  44503. get dPadRight(): number;
  44504. /**
  44505. * Sets the value of D-pad right
  44506. */
  44507. set dPadRight(value: number);
  44508. /**
  44509. * Force the gamepad to synchronize with device values
  44510. */
  44511. update(): void;
  44512. /**
  44513. * Disposes the gamepad
  44514. */
  44515. dispose(): void;
  44516. }
  44517. }
  44518. declare module BABYLON {
  44519. /**
  44520. * Manager for handling gamepads
  44521. */
  44522. export class GamepadManager {
  44523. private _scene?;
  44524. private _babylonGamepads;
  44525. private _oneGamepadConnected;
  44526. /** @hidden */
  44527. _isMonitoring: boolean;
  44528. private _gamepadEventSupported;
  44529. private _gamepadSupport?;
  44530. /**
  44531. * observable to be triggered when the gamepad controller has been connected
  44532. */
  44533. onGamepadConnectedObservable: Observable<Gamepad>;
  44534. /**
  44535. * observable to be triggered when the gamepad controller has been disconnected
  44536. */
  44537. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44538. private _onGamepadConnectedEvent;
  44539. private _onGamepadDisconnectedEvent;
  44540. /**
  44541. * Initializes the gamepad manager
  44542. * @param _scene BabylonJS scene
  44543. */
  44544. constructor(_scene?: Scene | undefined);
  44545. /**
  44546. * The gamepads in the game pad manager
  44547. */
  44548. get gamepads(): Gamepad[];
  44549. /**
  44550. * Get the gamepad controllers based on type
  44551. * @param type The type of gamepad controller
  44552. * @returns Nullable gamepad
  44553. */
  44554. getGamepadByType(type?: number): Nullable<Gamepad>;
  44555. /**
  44556. * Disposes the gamepad manager
  44557. */
  44558. dispose(): void;
  44559. private _addNewGamepad;
  44560. private _startMonitoringGamepads;
  44561. private _stopMonitoringGamepads;
  44562. /** @hidden */
  44563. _checkGamepadsStatus(): void;
  44564. private _updateGamepadObjects;
  44565. }
  44566. }
  44567. declare module BABYLON {
  44568. interface Scene {
  44569. /** @hidden */
  44570. _gamepadManager: Nullable<GamepadManager>;
  44571. /**
  44572. * Gets the gamepad manager associated with the scene
  44573. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44574. */
  44575. gamepadManager: GamepadManager;
  44576. }
  44577. /**
  44578. * Interface representing a free camera inputs manager
  44579. */
  44580. interface FreeCameraInputsManager {
  44581. /**
  44582. * Adds gamepad input support to the FreeCameraInputsManager.
  44583. * @returns the FreeCameraInputsManager
  44584. */
  44585. addGamepad(): FreeCameraInputsManager;
  44586. }
  44587. /**
  44588. * Interface representing an arc rotate camera inputs manager
  44589. */
  44590. interface ArcRotateCameraInputsManager {
  44591. /**
  44592. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44593. * @returns the camera inputs manager
  44594. */
  44595. addGamepad(): ArcRotateCameraInputsManager;
  44596. }
  44597. /**
  44598. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44599. */
  44600. export class GamepadSystemSceneComponent implements ISceneComponent {
  44601. /**
  44602. * The component name helpfull to identify the component in the list of scene components.
  44603. */
  44604. readonly name: string;
  44605. /**
  44606. * The scene the component belongs to.
  44607. */
  44608. scene: Scene;
  44609. /**
  44610. * Creates a new instance of the component for the given scene
  44611. * @param scene Defines the scene to register the component in
  44612. */
  44613. constructor(scene: Scene);
  44614. /**
  44615. * Registers the component in a given scene
  44616. */
  44617. register(): void;
  44618. /**
  44619. * Rebuilds the elements related to this component in case of
  44620. * context lost for instance.
  44621. */
  44622. rebuild(): void;
  44623. /**
  44624. * Disposes the component and the associated ressources
  44625. */
  44626. dispose(): void;
  44627. private _beforeCameraUpdate;
  44628. }
  44629. }
  44630. declare module BABYLON {
  44631. /**
  44632. * 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,
  44633. * which still works and will still be found in many Playgrounds.
  44634. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44635. */
  44636. export class UniversalCamera extends TouchCamera {
  44637. /**
  44638. * Defines the gamepad rotation sensiblity.
  44639. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44640. */
  44641. get gamepadAngularSensibility(): number;
  44642. set gamepadAngularSensibility(value: number);
  44643. /**
  44644. * Defines the gamepad move sensiblity.
  44645. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44646. */
  44647. get gamepadMoveSensibility(): number;
  44648. set gamepadMoveSensibility(value: number);
  44649. /**
  44650. * 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,
  44651. * which still works and will still be found in many Playgrounds.
  44652. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44653. * @param name Define the name of the camera in the scene
  44654. * @param position Define the start position of the camera in the scene
  44655. * @param scene Define the scene the camera belongs to
  44656. */
  44657. constructor(name: string, position: Vector3, scene: Scene);
  44658. /**
  44659. * Gets the current object class name.
  44660. * @return the class name
  44661. */
  44662. getClassName(): string;
  44663. }
  44664. }
  44665. declare module BABYLON {
  44666. /**
  44667. * This represents a FPS type of camera. This is only here for back compat purpose.
  44668. * Please use the UniversalCamera instead as both are identical.
  44669. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44670. */
  44671. export class GamepadCamera extends UniversalCamera {
  44672. /**
  44673. * Instantiates a new Gamepad Camera
  44674. * This represents a FPS type of camera. This is only here for back compat purpose.
  44675. * Please use the UniversalCamera instead as both are identical.
  44676. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44677. * @param name Define the name of the camera in the scene
  44678. * @param position Define the start position of the camera in the scene
  44679. * @param scene Define the scene the camera belongs to
  44680. */
  44681. constructor(name: string, position: Vector3, scene: Scene);
  44682. /**
  44683. * Gets the current object class name.
  44684. * @return the class name
  44685. */
  44686. getClassName(): string;
  44687. }
  44688. }
  44689. declare module BABYLON {
  44690. /** @hidden */
  44691. export var passPixelShader: {
  44692. name: string;
  44693. shader: string;
  44694. };
  44695. }
  44696. declare module BABYLON {
  44697. /** @hidden */
  44698. export var passCubePixelShader: {
  44699. name: string;
  44700. shader: string;
  44701. };
  44702. }
  44703. declare module BABYLON {
  44704. /**
  44705. * PassPostProcess which produces an output the same as it's input
  44706. */
  44707. export class PassPostProcess extends PostProcess {
  44708. /**
  44709. * Creates the PassPostProcess
  44710. * @param name The name of the effect.
  44711. * @param options The required width/height ratio to downsize to before computing the render pass.
  44712. * @param camera The camera to apply the render pass to.
  44713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44714. * @param engine The engine which the post process will be applied. (default: current engine)
  44715. * @param reusable If the post process can be reused on the same frame. (default: false)
  44716. * @param textureType The type of texture to be used when performing the post processing.
  44717. * @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)
  44718. */
  44719. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44720. }
  44721. /**
  44722. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44723. */
  44724. export class PassCubePostProcess extends PostProcess {
  44725. private _face;
  44726. /**
  44727. * Gets or sets the cube face to display.
  44728. * * 0 is +X
  44729. * * 1 is -X
  44730. * * 2 is +Y
  44731. * * 3 is -Y
  44732. * * 4 is +Z
  44733. * * 5 is -Z
  44734. */
  44735. get face(): number;
  44736. set face(value: number);
  44737. /**
  44738. * Creates the PassCubePostProcess
  44739. * @param name The name of the effect.
  44740. * @param options The required width/height ratio to downsize to before computing the render pass.
  44741. * @param camera The camera to apply the render pass to.
  44742. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44743. * @param engine The engine which the post process will be applied. (default: current engine)
  44744. * @param reusable If the post process can be reused on the same frame. (default: false)
  44745. * @param textureType The type of texture to be used when performing the post processing.
  44746. * @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)
  44747. */
  44748. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44749. }
  44750. }
  44751. declare module BABYLON {
  44752. /** @hidden */
  44753. export var anaglyphPixelShader: {
  44754. name: string;
  44755. shader: string;
  44756. };
  44757. }
  44758. declare module BABYLON {
  44759. /**
  44760. * Postprocess used to generate anaglyphic rendering
  44761. */
  44762. export class AnaglyphPostProcess extends PostProcess {
  44763. private _passedProcess;
  44764. /**
  44765. * Creates a new AnaglyphPostProcess
  44766. * @param name defines postprocess name
  44767. * @param options defines creation options or target ratio scale
  44768. * @param rigCameras defines cameras using this postprocess
  44769. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  44770. * @param engine defines hosting engine
  44771. * @param reusable defines if the postprocess will be reused multiple times per frame
  44772. */
  44773. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  44774. }
  44775. }
  44776. declare module BABYLON {
  44777. /**
  44778. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  44779. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44780. */
  44781. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  44782. /**
  44783. * Creates a new AnaglyphArcRotateCamera
  44784. * @param name defines camera name
  44785. * @param alpha defines alpha angle (in radians)
  44786. * @param beta defines beta angle (in radians)
  44787. * @param radius defines radius
  44788. * @param target defines camera target
  44789. * @param interaxialDistance defines distance between each color axis
  44790. * @param scene defines the hosting scene
  44791. */
  44792. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  44793. /**
  44794. * Gets camera class name
  44795. * @returns AnaglyphArcRotateCamera
  44796. */
  44797. getClassName(): string;
  44798. }
  44799. }
  44800. declare module BABYLON {
  44801. /**
  44802. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  44803. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44804. */
  44805. export class AnaglyphFreeCamera extends FreeCamera {
  44806. /**
  44807. * Creates a new AnaglyphFreeCamera
  44808. * @param name defines camera name
  44809. * @param position defines initial position
  44810. * @param interaxialDistance defines distance between each color axis
  44811. * @param scene defines the hosting scene
  44812. */
  44813. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44814. /**
  44815. * Gets camera class name
  44816. * @returns AnaglyphFreeCamera
  44817. */
  44818. getClassName(): string;
  44819. }
  44820. }
  44821. declare module BABYLON {
  44822. /**
  44823. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  44824. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44825. */
  44826. export class AnaglyphGamepadCamera extends GamepadCamera {
  44827. /**
  44828. * Creates a new AnaglyphGamepadCamera
  44829. * @param name defines camera name
  44830. * @param position defines initial position
  44831. * @param interaxialDistance defines distance between each color axis
  44832. * @param scene defines the hosting scene
  44833. */
  44834. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44835. /**
  44836. * Gets camera class name
  44837. * @returns AnaglyphGamepadCamera
  44838. */
  44839. getClassName(): string;
  44840. }
  44841. }
  44842. declare module BABYLON {
  44843. /**
  44844. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  44845. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44846. */
  44847. export class AnaglyphUniversalCamera extends UniversalCamera {
  44848. /**
  44849. * Creates a new AnaglyphUniversalCamera
  44850. * @param name defines camera name
  44851. * @param position defines initial position
  44852. * @param interaxialDistance defines distance between each color axis
  44853. * @param scene defines the hosting scene
  44854. */
  44855. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44856. /**
  44857. * Gets camera class name
  44858. * @returns AnaglyphUniversalCamera
  44859. */
  44860. getClassName(): string;
  44861. }
  44862. }
  44863. declare module BABYLON {
  44864. /**
  44865. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  44866. * @see http://doc.babylonjs.com/features/cameras
  44867. */
  44868. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  44869. /**
  44870. * Creates a new StereoscopicArcRotateCamera
  44871. * @param name defines camera name
  44872. * @param alpha defines alpha angle (in radians)
  44873. * @param beta defines beta angle (in radians)
  44874. * @param radius defines radius
  44875. * @param target defines camera target
  44876. * @param interaxialDistance defines distance between each color axis
  44877. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44878. * @param scene defines the hosting scene
  44879. */
  44880. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44881. /**
  44882. * Gets camera class name
  44883. * @returns StereoscopicArcRotateCamera
  44884. */
  44885. getClassName(): string;
  44886. }
  44887. }
  44888. declare module BABYLON {
  44889. /**
  44890. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  44891. * @see http://doc.babylonjs.com/features/cameras
  44892. */
  44893. export class StereoscopicFreeCamera extends FreeCamera {
  44894. /**
  44895. * Creates a new StereoscopicFreeCamera
  44896. * @param name defines camera name
  44897. * @param position defines initial position
  44898. * @param interaxialDistance defines distance between each color axis
  44899. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44900. * @param scene defines the hosting scene
  44901. */
  44902. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44903. /**
  44904. * Gets camera class name
  44905. * @returns StereoscopicFreeCamera
  44906. */
  44907. getClassName(): string;
  44908. }
  44909. }
  44910. declare module BABYLON {
  44911. /**
  44912. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  44913. * @see http://doc.babylonjs.com/features/cameras
  44914. */
  44915. export class StereoscopicGamepadCamera extends GamepadCamera {
  44916. /**
  44917. * Creates a new StereoscopicGamepadCamera
  44918. * @param name defines camera name
  44919. * @param position defines initial position
  44920. * @param interaxialDistance defines distance between each color axis
  44921. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44922. * @param scene defines the hosting scene
  44923. */
  44924. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44925. /**
  44926. * Gets camera class name
  44927. * @returns StereoscopicGamepadCamera
  44928. */
  44929. getClassName(): string;
  44930. }
  44931. }
  44932. declare module BABYLON {
  44933. /**
  44934. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  44935. * @see http://doc.babylonjs.com/features/cameras
  44936. */
  44937. export class StereoscopicUniversalCamera extends UniversalCamera {
  44938. /**
  44939. * Creates a new StereoscopicUniversalCamera
  44940. * @param name defines camera name
  44941. * @param position defines initial position
  44942. * @param interaxialDistance defines distance between each color axis
  44943. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44944. * @param scene defines the hosting scene
  44945. */
  44946. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44947. /**
  44948. * Gets camera class name
  44949. * @returns StereoscopicUniversalCamera
  44950. */
  44951. getClassName(): string;
  44952. }
  44953. }
  44954. declare module BABYLON {
  44955. /**
  44956. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  44957. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44958. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44959. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44960. */
  44961. export class VirtualJoysticksCamera extends FreeCamera {
  44962. /**
  44963. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  44964. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44965. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44966. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44967. * @param name Define the name of the camera in the scene
  44968. * @param position Define the start position of the camera in the scene
  44969. * @param scene Define the scene the camera belongs to
  44970. */
  44971. constructor(name: string, position: Vector3, scene: Scene);
  44972. /**
  44973. * Gets the current object class name.
  44974. * @return the class name
  44975. */
  44976. getClassName(): string;
  44977. }
  44978. }
  44979. declare module BABYLON {
  44980. /**
  44981. * This represents all the required metrics to create a VR camera.
  44982. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  44983. */
  44984. export class VRCameraMetrics {
  44985. /**
  44986. * Define the horizontal resolution off the screen.
  44987. */
  44988. hResolution: number;
  44989. /**
  44990. * Define the vertical resolution off the screen.
  44991. */
  44992. vResolution: number;
  44993. /**
  44994. * Define the horizontal screen size.
  44995. */
  44996. hScreenSize: number;
  44997. /**
  44998. * Define the vertical screen size.
  44999. */
  45000. vScreenSize: number;
  45001. /**
  45002. * Define the vertical screen center position.
  45003. */
  45004. vScreenCenter: number;
  45005. /**
  45006. * Define the distance of the eyes to the screen.
  45007. */
  45008. eyeToScreenDistance: number;
  45009. /**
  45010. * Define the distance between both lenses
  45011. */
  45012. lensSeparationDistance: number;
  45013. /**
  45014. * Define the distance between both viewer's eyes.
  45015. */
  45016. interpupillaryDistance: number;
  45017. /**
  45018. * Define the distortion factor of the VR postprocess.
  45019. * Please, touch with care.
  45020. */
  45021. distortionK: number[];
  45022. /**
  45023. * Define the chromatic aberration correction factors for the VR post process.
  45024. */
  45025. chromaAbCorrection: number[];
  45026. /**
  45027. * Define the scale factor of the post process.
  45028. * The smaller the better but the slower.
  45029. */
  45030. postProcessScaleFactor: number;
  45031. /**
  45032. * Define an offset for the lens center.
  45033. */
  45034. lensCenterOffset: number;
  45035. /**
  45036. * Define if the current vr camera should compensate the distortion of the lense or not.
  45037. */
  45038. compensateDistortion: boolean;
  45039. /**
  45040. * Defines if multiview should be enabled when rendering (Default: false)
  45041. */
  45042. multiviewEnabled: boolean;
  45043. /**
  45044. * Gets the rendering aspect ratio based on the provided resolutions.
  45045. */
  45046. get aspectRatio(): number;
  45047. /**
  45048. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45049. */
  45050. get aspectRatioFov(): number;
  45051. /**
  45052. * @hidden
  45053. */
  45054. get leftHMatrix(): Matrix;
  45055. /**
  45056. * @hidden
  45057. */
  45058. get rightHMatrix(): Matrix;
  45059. /**
  45060. * @hidden
  45061. */
  45062. get leftPreViewMatrix(): Matrix;
  45063. /**
  45064. * @hidden
  45065. */
  45066. get rightPreViewMatrix(): Matrix;
  45067. /**
  45068. * Get the default VRMetrics based on the most generic setup.
  45069. * @returns the default vr metrics
  45070. */
  45071. static GetDefault(): VRCameraMetrics;
  45072. }
  45073. }
  45074. declare module BABYLON {
  45075. /** @hidden */
  45076. export var vrDistortionCorrectionPixelShader: {
  45077. name: string;
  45078. shader: string;
  45079. };
  45080. }
  45081. declare module BABYLON {
  45082. /**
  45083. * VRDistortionCorrectionPostProcess used for mobile VR
  45084. */
  45085. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45086. private _isRightEye;
  45087. private _distortionFactors;
  45088. private _postProcessScaleFactor;
  45089. private _lensCenterOffset;
  45090. private _scaleIn;
  45091. private _scaleFactor;
  45092. private _lensCenter;
  45093. /**
  45094. * Initializes the VRDistortionCorrectionPostProcess
  45095. * @param name The name of the effect.
  45096. * @param camera The camera to apply the render pass to.
  45097. * @param isRightEye If this is for the right eye distortion
  45098. * @param vrMetrics All the required metrics for the VR camera
  45099. */
  45100. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45101. }
  45102. }
  45103. declare module BABYLON {
  45104. /**
  45105. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45106. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45107. */
  45108. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45109. /**
  45110. * Creates a new VRDeviceOrientationArcRotateCamera
  45111. * @param name defines camera name
  45112. * @param alpha defines the camera rotation along the logitudinal axis
  45113. * @param beta defines the camera rotation along the latitudinal axis
  45114. * @param radius defines the camera distance from its target
  45115. * @param target defines the camera target
  45116. * @param scene defines the scene the camera belongs to
  45117. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45118. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45119. */
  45120. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45121. /**
  45122. * Gets camera class name
  45123. * @returns VRDeviceOrientationArcRotateCamera
  45124. */
  45125. getClassName(): string;
  45126. }
  45127. }
  45128. declare module BABYLON {
  45129. /**
  45130. * Camera used to simulate VR rendering (based on FreeCamera)
  45131. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45132. */
  45133. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45134. /**
  45135. * Creates a new VRDeviceOrientationFreeCamera
  45136. * @param name defines camera name
  45137. * @param position defines the start position of the camera
  45138. * @param scene defines the scene the camera belongs to
  45139. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45140. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45141. */
  45142. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45143. /**
  45144. * Gets camera class name
  45145. * @returns VRDeviceOrientationFreeCamera
  45146. */
  45147. getClassName(): string;
  45148. }
  45149. }
  45150. declare module BABYLON {
  45151. /**
  45152. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45153. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45154. */
  45155. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45156. /**
  45157. * Creates a new VRDeviceOrientationGamepadCamera
  45158. * @param name defines camera name
  45159. * @param position defines the start position of the camera
  45160. * @param scene defines the scene the camera belongs to
  45161. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45162. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45163. */
  45164. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45165. /**
  45166. * Gets camera class name
  45167. * @returns VRDeviceOrientationGamepadCamera
  45168. */
  45169. getClassName(): string;
  45170. }
  45171. }
  45172. declare module BABYLON {
  45173. /** @hidden */
  45174. export var imageProcessingPixelShader: {
  45175. name: string;
  45176. shader: string;
  45177. };
  45178. }
  45179. declare module BABYLON {
  45180. /**
  45181. * ImageProcessingPostProcess
  45182. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45183. */
  45184. export class ImageProcessingPostProcess extends PostProcess {
  45185. /**
  45186. * Default configuration related to image processing available in the PBR Material.
  45187. */
  45188. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45189. /**
  45190. * Gets the image processing configuration used either in this material.
  45191. */
  45192. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45193. /**
  45194. * Sets the Default image processing configuration used either in the this material.
  45195. *
  45196. * If sets to null, the scene one is in use.
  45197. */
  45198. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45199. /**
  45200. * Keep track of the image processing observer to allow dispose and replace.
  45201. */
  45202. private _imageProcessingObserver;
  45203. /**
  45204. * Attaches a new image processing configuration to the PBR Material.
  45205. * @param configuration
  45206. */
  45207. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45208. /**
  45209. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45210. */
  45211. get colorCurves(): Nullable<ColorCurves>;
  45212. /**
  45213. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45214. */
  45215. set colorCurves(value: Nullable<ColorCurves>);
  45216. /**
  45217. * Gets wether the color curves effect is enabled.
  45218. */
  45219. get colorCurvesEnabled(): boolean;
  45220. /**
  45221. * Sets wether the color curves effect is enabled.
  45222. */
  45223. set colorCurvesEnabled(value: boolean);
  45224. /**
  45225. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45226. */
  45227. get colorGradingTexture(): Nullable<BaseTexture>;
  45228. /**
  45229. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45230. */
  45231. set colorGradingTexture(value: Nullable<BaseTexture>);
  45232. /**
  45233. * Gets wether the color grading effect is enabled.
  45234. */
  45235. get colorGradingEnabled(): boolean;
  45236. /**
  45237. * Gets wether the color grading effect is enabled.
  45238. */
  45239. set colorGradingEnabled(value: boolean);
  45240. /**
  45241. * Gets exposure used in the effect.
  45242. */
  45243. get exposure(): number;
  45244. /**
  45245. * Sets exposure used in the effect.
  45246. */
  45247. set exposure(value: number);
  45248. /**
  45249. * Gets wether tonemapping is enabled or not.
  45250. */
  45251. get toneMappingEnabled(): boolean;
  45252. /**
  45253. * Sets wether tonemapping is enabled or not
  45254. */
  45255. set toneMappingEnabled(value: boolean);
  45256. /**
  45257. * Gets the type of tone mapping effect.
  45258. */
  45259. get toneMappingType(): number;
  45260. /**
  45261. * Sets the type of tone mapping effect.
  45262. */
  45263. set toneMappingType(value: number);
  45264. /**
  45265. * Gets contrast used in the effect.
  45266. */
  45267. get contrast(): number;
  45268. /**
  45269. * Sets contrast used in the effect.
  45270. */
  45271. set contrast(value: number);
  45272. /**
  45273. * Gets Vignette stretch size.
  45274. */
  45275. get vignetteStretch(): number;
  45276. /**
  45277. * Sets Vignette stretch size.
  45278. */
  45279. set vignetteStretch(value: number);
  45280. /**
  45281. * Gets Vignette centre X Offset.
  45282. */
  45283. get vignetteCentreX(): number;
  45284. /**
  45285. * Sets Vignette centre X Offset.
  45286. */
  45287. set vignetteCentreX(value: number);
  45288. /**
  45289. * Gets Vignette centre Y Offset.
  45290. */
  45291. get vignetteCentreY(): number;
  45292. /**
  45293. * Sets Vignette centre Y Offset.
  45294. */
  45295. set vignetteCentreY(value: number);
  45296. /**
  45297. * Gets Vignette weight or intensity of the vignette effect.
  45298. */
  45299. get vignetteWeight(): number;
  45300. /**
  45301. * Sets Vignette weight or intensity of the vignette effect.
  45302. */
  45303. set vignetteWeight(value: number);
  45304. /**
  45305. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45306. * if vignetteEnabled is set to true.
  45307. */
  45308. get vignetteColor(): Color4;
  45309. /**
  45310. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45311. * if vignetteEnabled is set to true.
  45312. */
  45313. set vignetteColor(value: Color4);
  45314. /**
  45315. * Gets Camera field of view used by the Vignette effect.
  45316. */
  45317. get vignetteCameraFov(): number;
  45318. /**
  45319. * Sets Camera field of view used by the Vignette effect.
  45320. */
  45321. set vignetteCameraFov(value: number);
  45322. /**
  45323. * Gets the vignette blend mode allowing different kind of effect.
  45324. */
  45325. get vignetteBlendMode(): number;
  45326. /**
  45327. * Sets the vignette blend mode allowing different kind of effect.
  45328. */
  45329. set vignetteBlendMode(value: number);
  45330. /**
  45331. * Gets wether the vignette effect is enabled.
  45332. */
  45333. get vignetteEnabled(): boolean;
  45334. /**
  45335. * Sets wether the vignette effect is enabled.
  45336. */
  45337. set vignetteEnabled(value: boolean);
  45338. private _fromLinearSpace;
  45339. /**
  45340. * Gets wether the input of the processing is in Gamma or Linear Space.
  45341. */
  45342. get fromLinearSpace(): boolean;
  45343. /**
  45344. * Sets wether the input of the processing is in Gamma or Linear Space.
  45345. */
  45346. set fromLinearSpace(value: boolean);
  45347. /**
  45348. * Defines cache preventing GC.
  45349. */
  45350. private _defines;
  45351. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45352. /**
  45353. * "ImageProcessingPostProcess"
  45354. * @returns "ImageProcessingPostProcess"
  45355. */
  45356. getClassName(): string;
  45357. protected _updateParameters(): void;
  45358. dispose(camera?: Camera): void;
  45359. }
  45360. }
  45361. declare module BABYLON {
  45362. /**
  45363. * Class containing static functions to help procedurally build meshes
  45364. */
  45365. export class GroundBuilder {
  45366. /**
  45367. * Creates a ground mesh
  45368. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45369. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45371. * @param name defines the name of the mesh
  45372. * @param options defines the options used to create the mesh
  45373. * @param scene defines the hosting scene
  45374. * @returns the ground mesh
  45375. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45376. */
  45377. static CreateGround(name: string, options: {
  45378. width?: number;
  45379. height?: number;
  45380. subdivisions?: number;
  45381. subdivisionsX?: number;
  45382. subdivisionsY?: number;
  45383. updatable?: boolean;
  45384. }, scene: any): Mesh;
  45385. /**
  45386. * Creates a tiled ground mesh
  45387. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45388. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45389. * * 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
  45390. * * 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
  45391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45392. * @param name defines the name of the mesh
  45393. * @param options defines the options used to create the mesh
  45394. * @param scene defines the hosting scene
  45395. * @returns the tiled ground mesh
  45396. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45397. */
  45398. static CreateTiledGround(name: string, options: {
  45399. xmin: number;
  45400. zmin: number;
  45401. xmax: number;
  45402. zmax: number;
  45403. subdivisions?: {
  45404. w: number;
  45405. h: number;
  45406. };
  45407. precision?: {
  45408. w: number;
  45409. h: number;
  45410. };
  45411. updatable?: boolean;
  45412. }, scene?: Nullable<Scene>): Mesh;
  45413. /**
  45414. * Creates a ground mesh from a height map
  45415. * * The parameter `url` sets the URL of the height map image resource.
  45416. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45417. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45418. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45419. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45420. * * 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.
  45421. * * 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).
  45422. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45424. * @param name defines the name of the mesh
  45425. * @param url defines the url to the height map
  45426. * @param options defines the options used to create the mesh
  45427. * @param scene defines the hosting scene
  45428. * @returns the ground mesh
  45429. * @see https://doc.babylonjs.com/babylon101/height_map
  45430. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45431. */
  45432. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45433. width?: number;
  45434. height?: number;
  45435. subdivisions?: number;
  45436. minHeight?: number;
  45437. maxHeight?: number;
  45438. colorFilter?: Color3;
  45439. alphaFilter?: number;
  45440. updatable?: boolean;
  45441. onReady?: (mesh: GroundMesh) => void;
  45442. }, scene?: Nullable<Scene>): GroundMesh;
  45443. }
  45444. }
  45445. declare module BABYLON {
  45446. /**
  45447. * Class containing static functions to help procedurally build meshes
  45448. */
  45449. export class TorusBuilder {
  45450. /**
  45451. * Creates a torus mesh
  45452. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45453. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45454. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45455. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45456. * * 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
  45457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45458. * @param name defines the name of the mesh
  45459. * @param options defines the options used to create the mesh
  45460. * @param scene defines the hosting scene
  45461. * @returns the torus mesh
  45462. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45463. */
  45464. static CreateTorus(name: string, options: {
  45465. diameter?: number;
  45466. thickness?: number;
  45467. tessellation?: number;
  45468. updatable?: boolean;
  45469. sideOrientation?: number;
  45470. frontUVs?: Vector4;
  45471. backUVs?: Vector4;
  45472. }, scene: any): Mesh;
  45473. }
  45474. }
  45475. declare module BABYLON {
  45476. /**
  45477. * Class containing static functions to help procedurally build meshes
  45478. */
  45479. export class CylinderBuilder {
  45480. /**
  45481. * Creates a cylinder or a cone mesh
  45482. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45483. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45484. * * 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.
  45485. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45486. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45487. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45488. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45489. * * 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).
  45490. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45491. * * 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).
  45492. * * 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
  45493. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45494. * * 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
  45495. * * 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.
  45496. * * If `enclose` is false, a ring surface is one element.
  45497. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45498. * * 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
  45499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45500. * * 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
  45501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45502. * @param name defines the name of the mesh
  45503. * @param options defines the options used to create the mesh
  45504. * @param scene defines the hosting scene
  45505. * @returns the cylinder mesh
  45506. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45507. */
  45508. static CreateCylinder(name: string, options: {
  45509. height?: number;
  45510. diameterTop?: number;
  45511. diameterBottom?: number;
  45512. diameter?: number;
  45513. tessellation?: number;
  45514. subdivisions?: number;
  45515. arc?: number;
  45516. faceColors?: Color4[];
  45517. faceUV?: Vector4[];
  45518. updatable?: boolean;
  45519. hasRings?: boolean;
  45520. enclose?: boolean;
  45521. cap?: number;
  45522. sideOrientation?: number;
  45523. frontUVs?: Vector4;
  45524. backUVs?: Vector4;
  45525. }, scene: any): Mesh;
  45526. }
  45527. }
  45528. declare module BABYLON {
  45529. /**
  45530. * States of the webXR experience
  45531. */
  45532. export enum WebXRState {
  45533. /**
  45534. * Transitioning to being in XR mode
  45535. */
  45536. ENTERING_XR = 0,
  45537. /**
  45538. * Transitioning to non XR mode
  45539. */
  45540. EXITING_XR = 1,
  45541. /**
  45542. * In XR mode and presenting
  45543. */
  45544. IN_XR = 2,
  45545. /**
  45546. * Not entered XR mode
  45547. */
  45548. NOT_IN_XR = 3
  45549. }
  45550. /**
  45551. * Abstraction of the XR render target
  45552. */
  45553. export interface WebXRRenderTarget extends IDisposable {
  45554. /**
  45555. * xrpresent context of the canvas which can be used to display/mirror xr content
  45556. */
  45557. canvasContext: WebGLRenderingContext;
  45558. /**
  45559. * xr layer for the canvas
  45560. */
  45561. xrLayer: Nullable<XRWebGLLayer>;
  45562. /**
  45563. * Initializes the xr layer for the session
  45564. * @param xrSession xr session
  45565. * @returns a promise that will resolve once the XR Layer has been created
  45566. */
  45567. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45568. }
  45569. }
  45570. declare module BABYLON {
  45571. /**
  45572. * COnfiguration object for WebXR output canvas
  45573. */
  45574. export class WebXRManagedOutputCanvasOptions {
  45575. /**
  45576. * An optional canvas in case you wish to create it yourself and provide it here.
  45577. * If not provided, a new canvas will be created
  45578. */
  45579. canvasElement?: HTMLCanvasElement;
  45580. /**
  45581. * Options for this XR Layer output
  45582. */
  45583. canvasOptions?: XRWebGLLayerOptions;
  45584. /**
  45585. * CSS styling for a newly created canvas (if not provided)
  45586. */
  45587. newCanvasCssStyle?: string;
  45588. /**
  45589. * Get the default values of the configuration object
  45590. * @returns default values of this configuration object
  45591. */
  45592. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45593. }
  45594. /**
  45595. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45596. */
  45597. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45598. private _options;
  45599. private _canvas;
  45600. private _engine;
  45601. /**
  45602. * Rendering context of the canvas which can be used to display/mirror xr content
  45603. */
  45604. canvasContext: WebGLRenderingContext;
  45605. /**
  45606. * xr layer for the canvas
  45607. */
  45608. xrLayer: Nullable<XRWebGLLayer>;
  45609. /**
  45610. * Initializes the canvas to be added/removed upon entering/exiting xr
  45611. * @param _xrSessionManager The XR Session manager
  45612. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45613. */
  45614. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45615. /**
  45616. * Disposes of the object
  45617. */
  45618. dispose(): void;
  45619. /**
  45620. * Initializes the xr layer for the session
  45621. * @param xrSession xr session
  45622. * @returns a promise that will resolve once the XR Layer has been created
  45623. */
  45624. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45625. private _addCanvas;
  45626. private _removeCanvas;
  45627. private _setManagedOutputCanvas;
  45628. }
  45629. }
  45630. declare module BABYLON {
  45631. /**
  45632. * Manages an XRSession to work with Babylon's engine
  45633. * @see https://doc.babylonjs.com/how_to/webxr
  45634. */
  45635. export class WebXRSessionManager implements IDisposable {
  45636. /** The scene which the session should be created for */
  45637. scene: Scene;
  45638. private _referenceSpace;
  45639. private _rttProvider;
  45640. private _sessionEnded;
  45641. private _xrNavigator;
  45642. private baseLayer;
  45643. /**
  45644. * The base reference space from which the session started. good if you want to reset your
  45645. * reference space
  45646. */
  45647. baseReferenceSpace: XRReferenceSpace;
  45648. /**
  45649. * Current XR frame
  45650. */
  45651. currentFrame: Nullable<XRFrame>;
  45652. /** WebXR timestamp updated every frame */
  45653. currentTimestamp: number;
  45654. /**
  45655. * Used just in case of a failure to initialize an immersive session.
  45656. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45657. */
  45658. defaultHeightCompensation: number;
  45659. /**
  45660. * Fires every time a new xrFrame arrives which can be used to update the camera
  45661. */
  45662. onXRFrameObservable: Observable<XRFrame>;
  45663. /**
  45664. * Fires when the reference space changed
  45665. */
  45666. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45667. /**
  45668. * Fires when the xr session is ended either by the device or manually done
  45669. */
  45670. onXRSessionEnded: Observable<any>;
  45671. /**
  45672. * Fires when the xr session is ended either by the device or manually done
  45673. */
  45674. onXRSessionInit: Observable<XRSession>;
  45675. /**
  45676. * Underlying xr session
  45677. */
  45678. session: XRSession;
  45679. /**
  45680. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45681. * or get the offset the player is currently at.
  45682. */
  45683. viewerReferenceSpace: XRReferenceSpace;
  45684. /**
  45685. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45686. * @param scene The scene which the session should be created for
  45687. */
  45688. constructor(
  45689. /** The scene which the session should be created for */
  45690. scene: Scene);
  45691. /**
  45692. * The current reference space used in this session. This reference space can constantly change!
  45693. * It is mainly used to offset the camera's position.
  45694. */
  45695. get referenceSpace(): XRReferenceSpace;
  45696. /**
  45697. * Set a new reference space and triggers the observable
  45698. */
  45699. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45700. /**
  45701. * Disposes of the session manager
  45702. */
  45703. dispose(): void;
  45704. /**
  45705. * Stops the xrSession and restores the render loop
  45706. * @returns Promise which resolves after it exits XR
  45707. */
  45708. exitXRAsync(): Promise<void>;
  45709. /**
  45710. * Gets the correct render target texture to be rendered this frame for this eye
  45711. * @param eye the eye for which to get the render target
  45712. * @returns the render target for the specified eye
  45713. */
  45714. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  45715. /**
  45716. * Creates a WebXRRenderTarget object for the XR session
  45717. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  45718. * @param options optional options to provide when creating a new render target
  45719. * @returns a WebXR render target to which the session can render
  45720. */
  45721. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  45722. /**
  45723. * Initializes the manager
  45724. * After initialization enterXR can be called to start an XR session
  45725. * @returns Promise which resolves after it is initialized
  45726. */
  45727. initializeAsync(): Promise<void>;
  45728. /**
  45729. * Initializes an xr session
  45730. * @param xrSessionMode mode to initialize
  45731. * @param xrSessionInit defines optional and required values to pass to the session builder
  45732. * @returns a promise which will resolve once the session has been initialized
  45733. */
  45734. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  45735. /**
  45736. * Checks if a session would be supported for the creation options specified
  45737. * @param sessionMode session mode to check if supported eg. immersive-vr
  45738. * @returns A Promise that resolves to true if supported and false if not
  45739. */
  45740. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45741. /**
  45742. * Resets the reference space to the one started the session
  45743. */
  45744. resetReferenceSpace(): void;
  45745. /**
  45746. * Starts rendering to the xr layer
  45747. */
  45748. runXRRenderLoop(): void;
  45749. /**
  45750. * Sets the reference space on the xr session
  45751. * @param referenceSpaceType space to set
  45752. * @returns a promise that will resolve once the reference space has been set
  45753. */
  45754. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  45755. /**
  45756. * Updates the render state of the session
  45757. * @param state state to set
  45758. * @returns a promise that resolves once the render state has been updated
  45759. */
  45760. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  45761. /**
  45762. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  45763. * @param sessionMode defines the session to test
  45764. * @returns a promise with boolean as final value
  45765. */
  45766. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45767. private _createRenderTargetTexture;
  45768. }
  45769. }
  45770. declare module BABYLON {
  45771. /**
  45772. * WebXR Camera which holds the views for the xrSession
  45773. * @see https://doc.babylonjs.com/how_to/webxr_camera
  45774. */
  45775. export class WebXRCamera extends FreeCamera {
  45776. private _xrSessionManager;
  45777. private _firstFrame;
  45778. private _referenceQuaternion;
  45779. private _referencedPosition;
  45780. private _xrInvPositionCache;
  45781. private _xrInvQuaternionCache;
  45782. /**
  45783. * Should position compensation execute on first frame.
  45784. * This is used when copying the position from a native (non XR) camera
  45785. */
  45786. compensateOnFirstFrame: boolean;
  45787. /**
  45788. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  45789. * @param name the name of the camera
  45790. * @param scene the scene to add the camera to
  45791. * @param _xrSessionManager a constructed xr session manager
  45792. */
  45793. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  45794. /**
  45795. * Return the user's height, unrelated to the current ground.
  45796. * This will be the y position of this camera, when ground level is 0.
  45797. */
  45798. get realWorldHeight(): number;
  45799. /** @hidden */
  45800. _updateForDualEyeDebugging(): void;
  45801. /**
  45802. * Sets this camera's transformation based on a non-vr camera
  45803. * @param otherCamera the non-vr camera to copy the transformation from
  45804. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  45805. */
  45806. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  45807. /**
  45808. * Gets the current instance class name ("WebXRCamera").
  45809. * @returns the class name
  45810. */
  45811. getClassName(): string;
  45812. /**
  45813. * Overriding the _getViewMatrix function, as it is computed by WebXR
  45814. */
  45815. _getViewMatrix(): Matrix;
  45816. private _updateFromXRSession;
  45817. private _updateNumberOfRigCameras;
  45818. private _updateReferenceSpace;
  45819. private _updateReferenceSpaceOffset;
  45820. }
  45821. }
  45822. declare module BABYLON {
  45823. /**
  45824. * Defining the interface required for a (webxr) feature
  45825. */
  45826. export interface IWebXRFeature extends IDisposable {
  45827. /**
  45828. * Is this feature attached
  45829. */
  45830. attached: boolean;
  45831. /**
  45832. * Should auto-attach be disabled?
  45833. */
  45834. disableAutoAttach: boolean;
  45835. /**
  45836. * Attach the feature to the session
  45837. * Will usually be called by the features manager
  45838. *
  45839. * @param force should attachment be forced (even when already attached)
  45840. * @returns true if successful.
  45841. */
  45842. attach(force?: boolean): boolean;
  45843. /**
  45844. * Detach the feature from the session
  45845. * Will usually be called by the features manager
  45846. *
  45847. * @returns true if successful.
  45848. */
  45849. detach(): boolean;
  45850. }
  45851. /**
  45852. * A list of the currently available features without referencing them
  45853. */
  45854. export class WebXRFeatureName {
  45855. /**
  45856. * The name of the anchor system feature
  45857. */
  45858. static ANCHOR_SYSTEM: string;
  45859. /**
  45860. * The name of the background remover feature
  45861. */
  45862. static BACKGROUND_REMOVER: string;
  45863. /**
  45864. * The name of the hit test feature
  45865. */
  45866. static HIT_TEST: string;
  45867. /**
  45868. * physics impostors for xr controllers feature
  45869. */
  45870. static PHYSICS_CONTROLLERS: string;
  45871. /**
  45872. * The name of the plane detection feature
  45873. */
  45874. static PLANE_DETECTION: string;
  45875. /**
  45876. * The name of the pointer selection feature
  45877. */
  45878. static POINTER_SELECTION: string;
  45879. /**
  45880. * The name of the teleportation feature
  45881. */
  45882. static TELEPORTATION: string;
  45883. }
  45884. /**
  45885. * Defining the constructor of a feature. Used to register the modules.
  45886. */
  45887. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  45888. /**
  45889. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  45890. * It is mainly used in AR sessions.
  45891. *
  45892. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  45893. */
  45894. export class WebXRFeaturesManager implements IDisposable {
  45895. private _xrSessionManager;
  45896. private static readonly _AvailableFeatures;
  45897. private _features;
  45898. /**
  45899. * constructs a new features manages.
  45900. *
  45901. * @param _xrSessionManager an instance of WebXRSessionManager
  45902. */
  45903. constructor(_xrSessionManager: WebXRSessionManager);
  45904. /**
  45905. * Used to register a module. After calling this function a developer can use this feature in the scene.
  45906. * Mainly used internally.
  45907. *
  45908. * @param featureName the name of the feature to register
  45909. * @param constructorFunction the function used to construct the module
  45910. * @param version the (babylon) version of the module
  45911. * @param stable is that a stable version of this module
  45912. */
  45913. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  45914. /**
  45915. * Returns a constructor of a specific feature.
  45916. *
  45917. * @param featureName the name of the feature to construct
  45918. * @param version the version of the feature to load
  45919. * @param xrSessionManager the xrSessionManager. Used to construct the module
  45920. * @param options optional options provided to the module.
  45921. * @returns a function that, when called, will return a new instance of this feature
  45922. */
  45923. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  45924. /**
  45925. * Can be used to return the list of features currently registered
  45926. *
  45927. * @returns an Array of available features
  45928. */
  45929. static GetAvailableFeatures(): string[];
  45930. /**
  45931. * Gets the versions available for a specific feature
  45932. * @param featureName the name of the feature
  45933. * @returns an array with the available versions
  45934. */
  45935. static GetAvailableVersions(featureName: string): string[];
  45936. /**
  45937. * Return the latest unstable version of this feature
  45938. * @param featureName the name of the feature to search
  45939. * @returns the version number. if not found will return -1
  45940. */
  45941. static GetLatestVersionOfFeature(featureName: string): number;
  45942. /**
  45943. * Return the latest stable version of this feature
  45944. * @param featureName the name of the feature to search
  45945. * @returns the version number. if not found will return -1
  45946. */
  45947. static GetStableVersionOfFeature(featureName: string): number;
  45948. /**
  45949. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  45950. * Can be used during a session to start a feature
  45951. * @param featureName the name of feature to attach
  45952. */
  45953. attachFeature(featureName: string): void;
  45954. /**
  45955. * Can be used inside a session or when the session ends to detach a specific feature
  45956. * @param featureName the name of the feature to detach
  45957. */
  45958. detachFeature(featureName: string): void;
  45959. /**
  45960. * Used to disable an already-enabled feature
  45961. * The feature will be disposed and will be recreated once enabled.
  45962. * @param featureName the feature to disable
  45963. * @returns true if disable was successful
  45964. */
  45965. disableFeature(featureName: string | {
  45966. Name: string;
  45967. }): boolean;
  45968. /**
  45969. * dispose this features manager
  45970. */
  45971. dispose(): void;
  45972. /**
  45973. * 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.
  45974. * 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.
  45975. *
  45976. * @param featureName the name of the feature to load or the class of the feature
  45977. * @param version optional version to load. if not provided the latest version will be enabled
  45978. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  45979. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  45980. * @returns a new constructed feature or throws an error if feature not found.
  45981. */
  45982. enableFeature(featureName: string | {
  45983. Name: string;
  45984. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  45985. /**
  45986. * get the implementation of an enabled feature.
  45987. * @param featureName the name of the feature to load
  45988. * @returns the feature class, if found
  45989. */
  45990. getEnabledFeature(featureName: string): IWebXRFeature;
  45991. /**
  45992. * Get the list of enabled features
  45993. * @returns an array of enabled features
  45994. */
  45995. getEnabledFeatures(): string[];
  45996. }
  45997. }
  45998. declare module BABYLON {
  45999. /**
  46000. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46001. * @see https://doc.babylonjs.com/how_to/webxr
  46002. */
  46003. export class WebXRExperienceHelper implements IDisposable {
  46004. private scene;
  46005. private _nonVRCamera;
  46006. private _originalSceneAutoClear;
  46007. private _supported;
  46008. /**
  46009. * Camera used to render xr content
  46010. */
  46011. camera: WebXRCamera;
  46012. /** A features manager for this xr session */
  46013. featuresManager: WebXRFeaturesManager;
  46014. /**
  46015. * Observers registered here will be triggered after the camera's initial transformation is set
  46016. * This can be used to set a different ground level or an extra rotation.
  46017. *
  46018. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46019. * to the position set after this observable is done executing.
  46020. */
  46021. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46022. /**
  46023. * Fires when the state of the experience helper has changed
  46024. */
  46025. onStateChangedObservable: Observable<WebXRState>;
  46026. /** Session manager used to keep track of xr session */
  46027. sessionManager: WebXRSessionManager;
  46028. /**
  46029. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46030. */
  46031. state: WebXRState;
  46032. /**
  46033. * Creates a WebXRExperienceHelper
  46034. * @param scene The scene the helper should be created in
  46035. */
  46036. private constructor();
  46037. /**
  46038. * Creates the experience helper
  46039. * @param scene the scene to attach the experience helper to
  46040. * @returns a promise for the experience helper
  46041. */
  46042. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46043. /**
  46044. * Disposes of the experience helper
  46045. */
  46046. dispose(): void;
  46047. /**
  46048. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46049. * @param sessionMode options for the XR session
  46050. * @param referenceSpaceType frame of reference of the XR session
  46051. * @param renderTarget the output canvas that will be used to enter XR mode
  46052. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46053. * @returns promise that resolves after xr mode has entered
  46054. */
  46055. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46056. /**
  46057. * Exits XR mode and returns the scene to its original state
  46058. * @returns promise that resolves after xr mode has exited
  46059. */
  46060. exitXRAsync(): Promise<void>;
  46061. private _nonXRToXRCamera;
  46062. private _setState;
  46063. }
  46064. }
  46065. declare module BABYLON {
  46066. /**
  46067. * X-Y values for axes in WebXR
  46068. */
  46069. export interface IWebXRMotionControllerAxesValue {
  46070. /**
  46071. * The value of the x axis
  46072. */
  46073. x: number;
  46074. /**
  46075. * The value of the y-axis
  46076. */
  46077. y: number;
  46078. }
  46079. /**
  46080. * changed / previous values for the values of this component
  46081. */
  46082. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46083. /**
  46084. * current (this frame) value
  46085. */
  46086. current: T;
  46087. /**
  46088. * previous (last change) value
  46089. */
  46090. previous: T;
  46091. }
  46092. /**
  46093. * Represents changes in the component between current frame and last values recorded
  46094. */
  46095. export interface IWebXRMotionControllerComponentChanges {
  46096. /**
  46097. * will be populated with previous and current values if axes changed
  46098. */
  46099. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46100. /**
  46101. * will be populated with previous and current values if pressed changed
  46102. */
  46103. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46104. /**
  46105. * will be populated with previous and current values if touched changed
  46106. */
  46107. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46108. /**
  46109. * will be populated with previous and current values if value changed
  46110. */
  46111. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46112. }
  46113. /**
  46114. * This class represents a single component (for example button or thumbstick) of a motion controller
  46115. */
  46116. export class WebXRControllerComponent implements IDisposable {
  46117. /**
  46118. * the id of this component
  46119. */
  46120. id: string;
  46121. /**
  46122. * the type of the component
  46123. */
  46124. type: MotionControllerComponentType;
  46125. private _buttonIndex;
  46126. private _axesIndices;
  46127. private _axes;
  46128. private _changes;
  46129. private _currentValue;
  46130. private _hasChanges;
  46131. private _pressed;
  46132. private _touched;
  46133. /**
  46134. * button component type
  46135. */
  46136. static BUTTON_TYPE: MotionControllerComponentType;
  46137. /**
  46138. * squeeze component type
  46139. */
  46140. static SQUEEZE_TYPE: MotionControllerComponentType;
  46141. /**
  46142. * Thumbstick component type
  46143. */
  46144. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46145. /**
  46146. * Touchpad component type
  46147. */
  46148. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46149. /**
  46150. * trigger component type
  46151. */
  46152. static TRIGGER_TYPE: MotionControllerComponentType;
  46153. /**
  46154. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46155. * the axes data changes
  46156. */
  46157. onAxisValueChangedObservable: Observable<{
  46158. x: number;
  46159. y: number;
  46160. }>;
  46161. /**
  46162. * Observers registered here will be triggered when the state of a button changes
  46163. * State change is either pressed / touched / value
  46164. */
  46165. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46166. /**
  46167. * Creates a new component for a motion controller.
  46168. * It is created by the motion controller itself
  46169. *
  46170. * @param id the id of this component
  46171. * @param type the type of the component
  46172. * @param _buttonIndex index in the buttons array of the gamepad
  46173. * @param _axesIndices indices of the values in the axes array of the gamepad
  46174. */
  46175. constructor(
  46176. /**
  46177. * the id of this component
  46178. */
  46179. id: string,
  46180. /**
  46181. * the type of the component
  46182. */
  46183. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46184. /**
  46185. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46186. */
  46187. get axes(): IWebXRMotionControllerAxesValue;
  46188. /**
  46189. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46190. */
  46191. get changes(): IWebXRMotionControllerComponentChanges;
  46192. /**
  46193. * Return whether or not the component changed the last frame
  46194. */
  46195. get hasChanges(): boolean;
  46196. /**
  46197. * is the button currently pressed
  46198. */
  46199. get pressed(): boolean;
  46200. /**
  46201. * is the button currently touched
  46202. */
  46203. get touched(): boolean;
  46204. /**
  46205. * Get the current value of this component
  46206. */
  46207. get value(): number;
  46208. /**
  46209. * Dispose this component
  46210. */
  46211. dispose(): void;
  46212. /**
  46213. * Are there axes correlating to this component
  46214. * @return true is axes data is available
  46215. */
  46216. isAxes(): boolean;
  46217. /**
  46218. * Is this component a button (hence - pressable)
  46219. * @returns true if can be pressed
  46220. */
  46221. isButton(): boolean;
  46222. /**
  46223. * update this component using the gamepad object it is in. Called on every frame
  46224. * @param nativeController the native gamepad controller object
  46225. */
  46226. update(nativeController: IMinimalMotionControllerObject): void;
  46227. }
  46228. }
  46229. declare module BABYLON {
  46230. /**
  46231. * Class used to represent data loading progression
  46232. */
  46233. export class SceneLoaderProgressEvent {
  46234. /** defines if data length to load can be evaluated */
  46235. readonly lengthComputable: boolean;
  46236. /** defines the loaded data length */
  46237. readonly loaded: number;
  46238. /** defines the data length to load */
  46239. readonly total: number;
  46240. /**
  46241. * Create a new progress event
  46242. * @param lengthComputable defines if data length to load can be evaluated
  46243. * @param loaded defines the loaded data length
  46244. * @param total defines the data length to load
  46245. */
  46246. constructor(
  46247. /** defines if data length to load can be evaluated */
  46248. lengthComputable: boolean,
  46249. /** defines the loaded data length */
  46250. loaded: number,
  46251. /** defines the data length to load */
  46252. total: number);
  46253. /**
  46254. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46255. * @param event defines the source event
  46256. * @returns a new SceneLoaderProgressEvent
  46257. */
  46258. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46259. }
  46260. /**
  46261. * Interface used by SceneLoader plugins to define supported file extensions
  46262. */
  46263. export interface ISceneLoaderPluginExtensions {
  46264. /**
  46265. * Defines the list of supported extensions
  46266. */
  46267. [extension: string]: {
  46268. isBinary: boolean;
  46269. };
  46270. }
  46271. /**
  46272. * Interface used by SceneLoader plugin factory
  46273. */
  46274. export interface ISceneLoaderPluginFactory {
  46275. /**
  46276. * Defines the name of the factory
  46277. */
  46278. name: string;
  46279. /**
  46280. * Function called to create a new plugin
  46281. * @return the new plugin
  46282. */
  46283. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46284. /**
  46285. * The callback that returns true if the data can be directly loaded.
  46286. * @param data string containing the file data
  46287. * @returns if the data can be loaded directly
  46288. */
  46289. canDirectLoad?(data: string): boolean;
  46290. }
  46291. /**
  46292. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46293. */
  46294. export interface ISceneLoaderPluginBase {
  46295. /**
  46296. * The friendly name of this plugin.
  46297. */
  46298. name: string;
  46299. /**
  46300. * The file extensions supported by this plugin.
  46301. */
  46302. extensions: string | ISceneLoaderPluginExtensions;
  46303. /**
  46304. * The callback called when loading from a url.
  46305. * @param scene scene loading this url
  46306. * @param url url to load
  46307. * @param onSuccess callback called when the file successfully loads
  46308. * @param onProgress callback called while file is loading (if the server supports this mode)
  46309. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46310. * @param onError callback called when the file fails to load
  46311. * @returns a file request object
  46312. */
  46313. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46314. /**
  46315. * The callback called when loading from a file object.
  46316. * @param scene scene loading this file
  46317. * @param file defines the file to load
  46318. * @param onSuccess defines the callback to call when data is loaded
  46319. * @param onProgress defines the callback to call during loading process
  46320. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46321. * @param onError defines the callback to call when an error occurs
  46322. * @returns a file request object
  46323. */
  46324. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46325. /**
  46326. * The callback that returns true if the data can be directly loaded.
  46327. * @param data string containing the file data
  46328. * @returns if the data can be loaded directly
  46329. */
  46330. canDirectLoad?(data: string): boolean;
  46331. /**
  46332. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46333. * @param scene scene loading this data
  46334. * @param data string containing the data
  46335. * @returns data to pass to the plugin
  46336. */
  46337. directLoad?(scene: Scene, data: string): any;
  46338. /**
  46339. * The callback that allows custom handling of the root url based on the response url.
  46340. * @param rootUrl the original root url
  46341. * @param responseURL the response url if available
  46342. * @returns the new root url
  46343. */
  46344. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46345. }
  46346. /**
  46347. * Interface used to define a SceneLoader plugin
  46348. */
  46349. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46350. /**
  46351. * Import meshes into a scene.
  46352. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46353. * @param scene The scene to import into
  46354. * @param data The data to import
  46355. * @param rootUrl The root url for scene and resources
  46356. * @param meshes The meshes array to import into
  46357. * @param particleSystems The particle systems array to import into
  46358. * @param skeletons The skeletons array to import into
  46359. * @param onError The callback when import fails
  46360. * @returns True if successful or false otherwise
  46361. */
  46362. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46363. /**
  46364. * Load into a scene.
  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 True if successful or false otherwise
  46370. */
  46371. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46372. /**
  46373. * Load into an asset container.
  46374. * @param scene The scene to load into
  46375. * @param data The data to import
  46376. * @param rootUrl The root url for scene and resources
  46377. * @param onError The callback when import fails
  46378. * @returns The loaded asset container
  46379. */
  46380. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46381. }
  46382. /**
  46383. * Interface used to define an async SceneLoader plugin
  46384. */
  46385. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46386. /**
  46387. * Import meshes into a scene.
  46388. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46389. * @param scene The scene to import into
  46390. * @param data The data to import
  46391. * @param rootUrl The root url for scene and resources
  46392. * @param onProgress The callback when the load progresses
  46393. * @param fileName Defines the name of the file to load
  46394. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46395. */
  46396. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46397. meshes: AbstractMesh[];
  46398. particleSystems: IParticleSystem[];
  46399. skeletons: Skeleton[];
  46400. animationGroups: AnimationGroup[];
  46401. }>;
  46402. /**
  46403. * Load into a scene.
  46404. * @param scene The scene to load into
  46405. * @param data The data to import
  46406. * @param rootUrl The root url for scene and resources
  46407. * @param onProgress The callback when the load progresses
  46408. * @param fileName Defines the name of the file to load
  46409. * @returns Nothing
  46410. */
  46411. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46412. /**
  46413. * Load into an asset container.
  46414. * @param scene The scene to load into
  46415. * @param data The data to import
  46416. * @param rootUrl The root url for scene and resources
  46417. * @param onProgress The callback when the load progresses
  46418. * @param fileName Defines the name of the file to load
  46419. * @returns The loaded asset container
  46420. */
  46421. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46422. }
  46423. /**
  46424. * Mode that determines how to handle old animation groups before loading new ones.
  46425. */
  46426. export enum SceneLoaderAnimationGroupLoadingMode {
  46427. /**
  46428. * Reset all old animations to initial state then dispose them.
  46429. */
  46430. Clean = 0,
  46431. /**
  46432. * Stop all old animations.
  46433. */
  46434. Stop = 1,
  46435. /**
  46436. * Restart old animations from first frame.
  46437. */
  46438. Sync = 2,
  46439. /**
  46440. * Old animations remains untouched.
  46441. */
  46442. NoSync = 3
  46443. }
  46444. /**
  46445. * Class used to load scene from various file formats using registered plugins
  46446. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46447. */
  46448. export class SceneLoader {
  46449. /**
  46450. * No logging while loading
  46451. */
  46452. static readonly NO_LOGGING: number;
  46453. /**
  46454. * Minimal logging while loading
  46455. */
  46456. static readonly MINIMAL_LOGGING: number;
  46457. /**
  46458. * Summary logging while loading
  46459. */
  46460. static readonly SUMMARY_LOGGING: number;
  46461. /**
  46462. * Detailled logging while loading
  46463. */
  46464. static readonly DETAILED_LOGGING: number;
  46465. /**
  46466. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46467. */
  46468. static get ForceFullSceneLoadingForIncremental(): boolean;
  46469. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46470. /**
  46471. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46472. */
  46473. static get ShowLoadingScreen(): boolean;
  46474. static set ShowLoadingScreen(value: boolean);
  46475. /**
  46476. * Defines the current logging level (while loading the scene)
  46477. * @ignorenaming
  46478. */
  46479. static get loggingLevel(): number;
  46480. static set loggingLevel(value: number);
  46481. /**
  46482. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46483. */
  46484. static get CleanBoneMatrixWeights(): boolean;
  46485. static set CleanBoneMatrixWeights(value: boolean);
  46486. /**
  46487. * Event raised when a plugin is used to load a scene
  46488. */
  46489. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46490. private static _registeredPlugins;
  46491. private static _getDefaultPlugin;
  46492. private static _getPluginForExtension;
  46493. private static _getPluginForDirectLoad;
  46494. private static _getPluginForFilename;
  46495. private static _getDirectLoad;
  46496. private static _loadData;
  46497. private static _getFileInfo;
  46498. /**
  46499. * Gets a plugin that can load the given extension
  46500. * @param extension defines the extension to load
  46501. * @returns a plugin or null if none works
  46502. */
  46503. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46504. /**
  46505. * Gets a boolean indicating that the given extension can be loaded
  46506. * @param extension defines the extension to load
  46507. * @returns true if the extension is supported
  46508. */
  46509. static IsPluginForExtensionAvailable(extension: string): boolean;
  46510. /**
  46511. * Adds a new plugin to the list of registered plugins
  46512. * @param plugin defines the plugin to add
  46513. */
  46514. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46515. /**
  46516. * Import meshes into a scene
  46517. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46518. * @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)
  46519. * @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)
  46520. * @param scene the instance of BABYLON.Scene to append to
  46521. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46522. * @param onProgress a callback with a progress event for each file being loaded
  46523. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46524. * @param pluginExtension the extension used to determine the plugin
  46525. * @returns The loaded plugin
  46526. */
  46527. 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>;
  46528. /**
  46529. * Import meshes into a scene
  46530. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46531. * @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)
  46532. * @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)
  46533. * @param scene the instance of BABYLON.Scene to append to
  46534. * @param onProgress a callback with a progress event for each file being loaded
  46535. * @param pluginExtension the extension used to determine the plugin
  46536. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46537. */
  46538. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46539. meshes: AbstractMesh[];
  46540. particleSystems: IParticleSystem[];
  46541. skeletons: Skeleton[];
  46542. animationGroups: AnimationGroup[];
  46543. }>;
  46544. /**
  46545. * Load a scene
  46546. * @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)
  46547. * @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)
  46548. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46549. * @param onSuccess a callback with the scene when import succeeds
  46550. * @param onProgress a callback with a progress event for each file being loaded
  46551. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46552. * @param pluginExtension the extension used to determine the plugin
  46553. * @returns The loaded plugin
  46554. */
  46555. 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>;
  46556. /**
  46557. * Load a scene
  46558. * @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)
  46559. * @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)
  46560. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46561. * @param onProgress a callback with a progress event for each file being loaded
  46562. * @param pluginExtension the extension used to determine the plugin
  46563. * @returns The loaded scene
  46564. */
  46565. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46566. /**
  46567. * Append a scene
  46568. * @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)
  46569. * @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)
  46570. * @param scene is the instance of BABYLON.Scene to append to
  46571. * @param onSuccess a callback with the scene when import succeeds
  46572. * @param onProgress a callback with a progress event for each file being loaded
  46573. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46574. * @param pluginExtension the extension used to determine the plugin
  46575. * @returns The loaded plugin
  46576. */
  46577. 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>;
  46578. /**
  46579. * Append a scene
  46580. * @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)
  46581. * @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)
  46582. * @param scene is the instance of BABYLON.Scene to append to
  46583. * @param onProgress a callback with a progress event for each file being loaded
  46584. * @param pluginExtension the extension used to determine the plugin
  46585. * @returns The given scene
  46586. */
  46587. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46588. /**
  46589. * Load a scene into an asset container
  46590. * @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)
  46591. * @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)
  46592. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46593. * @param onSuccess a callback with the scene when import succeeds
  46594. * @param onProgress a callback with a progress event for each file being loaded
  46595. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46596. * @param pluginExtension the extension used to determine the plugin
  46597. * @returns The loaded plugin
  46598. */
  46599. 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>;
  46600. /**
  46601. * Load a scene into an asset container
  46602. * @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)
  46603. * @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)
  46604. * @param scene is the instance of Scene to append to
  46605. * @param onProgress a callback with a progress event for each file being loaded
  46606. * @param pluginExtension the extension used to determine the plugin
  46607. * @returns The loaded asset container
  46608. */
  46609. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46610. /**
  46611. * Import animations from a file into a scene
  46612. * @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)
  46613. * @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)
  46614. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46615. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46616. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46617. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46618. * @param onSuccess a callback with the scene when import succeeds
  46619. * @param onProgress a callback with a progress event for each file being loaded
  46620. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46621. */
  46622. 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;
  46623. /**
  46624. * Import animations from a file into a scene
  46625. * @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)
  46626. * @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)
  46627. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46628. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46629. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46630. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46631. * @param onSuccess a callback with the scene when import succeeds
  46632. * @param onProgress a callback with a progress event for each file being loaded
  46633. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46634. * @returns the updated scene with imported animations
  46635. */
  46636. 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>;
  46637. }
  46638. }
  46639. declare module BABYLON {
  46640. /**
  46641. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46642. */
  46643. export type MotionControllerHandedness = "none" | "left" | "right";
  46644. /**
  46645. * The type of components available in motion controllers.
  46646. * This is not the name of the component.
  46647. */
  46648. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46649. /**
  46650. * The state of a controller component
  46651. */
  46652. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46653. /**
  46654. * The schema of motion controller layout.
  46655. * No object will be initialized using this interface
  46656. * This is used just to define the profile.
  46657. */
  46658. export interface IMotionControllerLayout {
  46659. /**
  46660. * Path to load the assets. Usually relative to the base path
  46661. */
  46662. assetPath: string;
  46663. /**
  46664. * Available components (unsorted)
  46665. */
  46666. components: {
  46667. /**
  46668. * A map of component Ids
  46669. */
  46670. [componentId: string]: {
  46671. /**
  46672. * The type of input the component outputs
  46673. */
  46674. type: MotionControllerComponentType;
  46675. /**
  46676. * The indices of this component in the gamepad object
  46677. */
  46678. gamepadIndices: {
  46679. /**
  46680. * Index of button
  46681. */
  46682. button?: number;
  46683. /**
  46684. * If available, index of x-axis
  46685. */
  46686. xAxis?: number;
  46687. /**
  46688. * If available, index of y-axis
  46689. */
  46690. yAxis?: number;
  46691. };
  46692. /**
  46693. * The mesh's root node name
  46694. */
  46695. rootNodeName: string;
  46696. /**
  46697. * Animation definitions for this model
  46698. */
  46699. visualResponses: {
  46700. [stateKey: string]: {
  46701. /**
  46702. * What property will be animated
  46703. */
  46704. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46705. /**
  46706. * What states influence this visual response
  46707. */
  46708. states: MotionControllerComponentStateType[];
  46709. /**
  46710. * Type of animation - movement or visibility
  46711. */
  46712. valueNodeProperty: "transform" | "visibility";
  46713. /**
  46714. * Base node name to move. Its position will be calculated according to the min and max nodes
  46715. */
  46716. valueNodeName?: string;
  46717. /**
  46718. * Minimum movement node
  46719. */
  46720. minNodeName?: string;
  46721. /**
  46722. * Max movement node
  46723. */
  46724. maxNodeName?: string;
  46725. };
  46726. };
  46727. /**
  46728. * If touch enabled, what is the name of node to display user feedback
  46729. */
  46730. touchPointNodeName?: string;
  46731. };
  46732. };
  46733. /**
  46734. * Is it xr standard mapping or not
  46735. */
  46736. gamepadMapping: "" | "xr-standard";
  46737. /**
  46738. * Base root node of this entire model
  46739. */
  46740. rootNodeName: string;
  46741. /**
  46742. * Defines the main button component id
  46743. */
  46744. selectComponentId: string;
  46745. }
  46746. /**
  46747. * A definition for the layout map in the input profile
  46748. */
  46749. export interface IMotionControllerLayoutMap {
  46750. /**
  46751. * Layouts with handedness type as a key
  46752. */
  46753. [handedness: string]: IMotionControllerLayout;
  46754. }
  46755. /**
  46756. * The XR Input profile schema
  46757. * Profiles can be found here:
  46758. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  46759. */
  46760. export interface IMotionControllerProfile {
  46761. /**
  46762. * fallback profiles for this profileId
  46763. */
  46764. fallbackProfileIds: string[];
  46765. /**
  46766. * The layout map, with handedness as key
  46767. */
  46768. layouts: IMotionControllerLayoutMap;
  46769. /**
  46770. * The id of this profile
  46771. * correlates to the profile(s) in the xrInput.profiles array
  46772. */
  46773. profileId: string;
  46774. }
  46775. /**
  46776. * A helper-interface for the 3 meshes needed for controller button animation
  46777. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  46778. */
  46779. export interface IMotionControllerButtonMeshMap {
  46780. /**
  46781. * the mesh that defines the pressed value mesh position.
  46782. * This is used to find the max-position of this button
  46783. */
  46784. pressedMesh: AbstractMesh;
  46785. /**
  46786. * the mesh that defines the unpressed value mesh position.
  46787. * This is used to find the min (or initial) position of this button
  46788. */
  46789. unpressedMesh: AbstractMesh;
  46790. /**
  46791. * The mesh that will be changed when value changes
  46792. */
  46793. valueMesh: AbstractMesh;
  46794. }
  46795. /**
  46796. * A helper-interface for the 3 meshes needed for controller axis animation.
  46797. * This will be expanded when touchpad animations are fully supported
  46798. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  46799. */
  46800. export interface IMotionControllerMeshMap {
  46801. /**
  46802. * the mesh that defines the maximum value mesh position.
  46803. */
  46804. maxMesh?: AbstractMesh;
  46805. /**
  46806. * the mesh that defines the minimum value mesh position.
  46807. */
  46808. minMesh?: AbstractMesh;
  46809. /**
  46810. * The mesh that will be changed when axis value changes
  46811. */
  46812. valueMesh: AbstractMesh;
  46813. }
  46814. /**
  46815. * The elements needed for change-detection of the gamepad objects in motion controllers
  46816. */
  46817. export interface IMinimalMotionControllerObject {
  46818. /**
  46819. * Available axes of this controller
  46820. */
  46821. axes: number[];
  46822. /**
  46823. * An array of available buttons
  46824. */
  46825. buttons: Array<{
  46826. /**
  46827. * Value of the button/trigger
  46828. */
  46829. value: number;
  46830. /**
  46831. * If the button/trigger is currently touched
  46832. */
  46833. touched: boolean;
  46834. /**
  46835. * If the button/trigger is currently pressed
  46836. */
  46837. pressed: boolean;
  46838. }>;
  46839. /**
  46840. * EXPERIMENTAL haptic support.
  46841. */
  46842. hapticActuators?: Array<{
  46843. pulse: (value: number, duration: number) => Promise<boolean>;
  46844. }>;
  46845. }
  46846. /**
  46847. * An Abstract Motion controller
  46848. * This class receives an xrInput and a profile layout and uses those to initialize the components
  46849. * Each component has an observable to check for changes in value and state
  46850. */
  46851. export abstract class WebXRAbstractMotionController implements IDisposable {
  46852. protected scene: Scene;
  46853. protected layout: IMotionControllerLayout;
  46854. /**
  46855. * The gamepad object correlating to this controller
  46856. */
  46857. gamepadObject: IMinimalMotionControllerObject;
  46858. /**
  46859. * handedness (left/right/none) of this controller
  46860. */
  46861. handedness: MotionControllerHandedness;
  46862. private _initComponent;
  46863. private _modelReady;
  46864. /**
  46865. * A map of components (WebXRControllerComponent) in this motion controller
  46866. * Components have a ComponentType and can also have both button and axis definitions
  46867. */
  46868. readonly components: {
  46869. [id: string]: WebXRControllerComponent;
  46870. };
  46871. /**
  46872. * Disable the model's animation. Can be set at any time.
  46873. */
  46874. disableAnimation: boolean;
  46875. /**
  46876. * Observers registered here will be triggered when the model of this controller is done loading
  46877. */
  46878. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  46879. /**
  46880. * The profile id of this motion controller
  46881. */
  46882. abstract profileId: string;
  46883. /**
  46884. * The root mesh of the model. It is null if the model was not yet initialized
  46885. */
  46886. rootMesh: Nullable<AbstractMesh>;
  46887. /**
  46888. * constructs a new abstract motion controller
  46889. * @param scene the scene to which the model of the controller will be added
  46890. * @param layout The profile layout to load
  46891. * @param gamepadObject The gamepad object correlating to this controller
  46892. * @param handedness handedness (left/right/none) of this controller
  46893. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  46894. */
  46895. constructor(scene: Scene, layout: IMotionControllerLayout,
  46896. /**
  46897. * The gamepad object correlating to this controller
  46898. */
  46899. gamepadObject: IMinimalMotionControllerObject,
  46900. /**
  46901. * handedness (left/right/none) of this controller
  46902. */
  46903. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  46904. /**
  46905. * Dispose this controller, the model mesh and all its components
  46906. */
  46907. dispose(): void;
  46908. /**
  46909. * Returns all components of specific type
  46910. * @param type the type to search for
  46911. * @return an array of components with this type
  46912. */
  46913. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  46914. /**
  46915. * get a component based an its component id as defined in layout.components
  46916. * @param id the id of the component
  46917. * @returns the component correlates to the id or undefined if not found
  46918. */
  46919. getComponent(id: string): WebXRControllerComponent;
  46920. /**
  46921. * Get the list of components available in this motion controller
  46922. * @returns an array of strings correlating to available components
  46923. */
  46924. getComponentIds(): string[];
  46925. /**
  46926. * Get the first component of specific type
  46927. * @param type type of component to find
  46928. * @return a controller component or null if not found
  46929. */
  46930. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  46931. /**
  46932. * Get the main (Select) component of this controller as defined in the layout
  46933. * @returns the main component of this controller
  46934. */
  46935. getMainComponent(): WebXRControllerComponent;
  46936. /**
  46937. * Loads the model correlating to this controller
  46938. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  46939. * @returns A promise fulfilled with the result of the model loading
  46940. */
  46941. loadModel(): Promise<boolean>;
  46942. /**
  46943. * Update this model using the current XRFrame
  46944. * @param xrFrame the current xr frame to use and update the model
  46945. */
  46946. updateFromXRFrame(xrFrame: XRFrame): void;
  46947. /**
  46948. * Backwards compatibility due to a deeply-integrated typo
  46949. */
  46950. get handness(): XREye;
  46951. /**
  46952. * Pulse (vibrate) this controller
  46953. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  46954. * Consecutive calls to this function will cancel the last pulse call
  46955. *
  46956. * @param value the strength of the pulse in 0.0...1.0 range
  46957. * @param duration Duration of the pulse in milliseconds
  46958. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  46959. * @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
  46960. */
  46961. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  46962. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46963. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46964. /**
  46965. * Moves the axis on the controller mesh based on its current state
  46966. * @param axis the index of the axis
  46967. * @param axisValue the value of the axis which determines the meshes new position
  46968. * @hidden
  46969. */
  46970. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  46971. /**
  46972. * Update the model itself with the current frame data
  46973. * @param xrFrame the frame to use for updating the model mesh
  46974. */
  46975. protected updateModel(xrFrame: XRFrame): void;
  46976. /**
  46977. * Get the filename and path for this controller's model
  46978. * @returns a map of filename and path
  46979. */
  46980. protected abstract _getFilenameAndPath(): {
  46981. filename: string;
  46982. path: string;
  46983. };
  46984. /**
  46985. * This function is called before the mesh is loaded. It checks for loading constraints.
  46986. * For example, this function can check if the GLB loader is available
  46987. * If this function returns false, the generic controller will be loaded instead
  46988. * @returns Is the client ready to load the mesh
  46989. */
  46990. protected abstract _getModelLoadingConstraints(): boolean;
  46991. /**
  46992. * This function will be called after the model was successfully loaded and can be used
  46993. * for mesh transformations before it is available for the user
  46994. * @param meshes the loaded meshes
  46995. */
  46996. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  46997. /**
  46998. * Set the root mesh for this controller. Important for the WebXR controller class
  46999. * @param meshes the loaded meshes
  47000. */
  47001. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47002. /**
  47003. * A function executed each frame that updates the mesh (if needed)
  47004. * @param xrFrame the current xrFrame
  47005. */
  47006. protected abstract _updateModel(xrFrame: XRFrame): void;
  47007. private _getGenericFilenameAndPath;
  47008. private _getGenericParentMesh;
  47009. }
  47010. }
  47011. declare module BABYLON {
  47012. /**
  47013. * A generic trigger-only motion controller for WebXR
  47014. */
  47015. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47016. /**
  47017. * Static version of the profile id of this controller
  47018. */
  47019. static ProfileId: string;
  47020. profileId: string;
  47021. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47022. protected _getFilenameAndPath(): {
  47023. filename: string;
  47024. path: string;
  47025. };
  47026. protected _getModelLoadingConstraints(): boolean;
  47027. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47028. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47029. protected _updateModel(): void;
  47030. }
  47031. }
  47032. declare module BABYLON {
  47033. /**
  47034. * Class containing static functions to help procedurally build meshes
  47035. */
  47036. export class SphereBuilder {
  47037. /**
  47038. * Creates a sphere mesh
  47039. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47040. * * 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`)
  47041. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47042. * * 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
  47043. * * 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)
  47044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47045. * * 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
  47046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47047. * @param name defines the name of the mesh
  47048. * @param options defines the options used to create the mesh
  47049. * @param scene defines the hosting scene
  47050. * @returns the sphere mesh
  47051. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47052. */
  47053. static CreateSphere(name: string, options: {
  47054. segments?: number;
  47055. diameter?: number;
  47056. diameterX?: number;
  47057. diameterY?: number;
  47058. diameterZ?: number;
  47059. arc?: number;
  47060. slice?: number;
  47061. sideOrientation?: number;
  47062. frontUVs?: Vector4;
  47063. backUVs?: Vector4;
  47064. updatable?: boolean;
  47065. }, scene?: Nullable<Scene>): Mesh;
  47066. }
  47067. }
  47068. declare module BABYLON {
  47069. /**
  47070. * A profiled motion controller has its profile loaded from an online repository.
  47071. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47072. */
  47073. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47074. private _repositoryUrl;
  47075. private _buttonMeshMapping;
  47076. private _touchDots;
  47077. /**
  47078. * The profile ID of this controller. Will be populated when the controller initializes.
  47079. */
  47080. profileId: string;
  47081. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47082. dispose(): void;
  47083. protected _getFilenameAndPath(): {
  47084. filename: string;
  47085. path: string;
  47086. };
  47087. protected _getModelLoadingConstraints(): boolean;
  47088. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47089. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47090. protected _updateModel(_xrFrame: XRFrame): void;
  47091. }
  47092. }
  47093. declare module BABYLON {
  47094. /**
  47095. * A construction function type to create a new controller based on an xrInput object
  47096. */
  47097. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47098. /**
  47099. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47100. *
  47101. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47102. * it should be replaced with auto-loaded controllers.
  47103. *
  47104. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47105. */
  47106. export class WebXRMotionControllerManager {
  47107. private static _AvailableControllers;
  47108. private static _Fallbacks;
  47109. private static _ProfileLoadingPromises;
  47110. private static _ProfilesList;
  47111. /**
  47112. * The base URL of the online controller repository. Can be changed at any time.
  47113. */
  47114. static BaseRepositoryUrl: string;
  47115. /**
  47116. * Which repository gets priority - local or online
  47117. */
  47118. static PrioritizeOnlineRepository: boolean;
  47119. /**
  47120. * Use the online repository, or use only locally-defined controllers
  47121. */
  47122. static UseOnlineRepository: boolean;
  47123. /**
  47124. * Clear the cache used for profile loading and reload when requested again
  47125. */
  47126. static ClearProfilesCache(): void;
  47127. /**
  47128. * Register the default fallbacks.
  47129. * This function is called automatically when this file is imported.
  47130. */
  47131. static DefaultFallbacks(): void;
  47132. /**
  47133. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47134. * @param profileId the profile to which a fallback needs to be found
  47135. * @return an array with corresponding fallback profiles
  47136. */
  47137. static FindFallbackWithProfileId(profileId: string): string[];
  47138. /**
  47139. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47140. * The order of search:
  47141. *
  47142. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47143. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47144. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47145. * 4) return the generic trigger controller if none were found
  47146. *
  47147. * @param xrInput the xrInput to which a new controller is initialized
  47148. * @param scene the scene to which the model will be added
  47149. * @param forceProfile force a certain profile for this controller
  47150. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47151. */
  47152. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47153. /**
  47154. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47155. *
  47156. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47157. *
  47158. * @param type the profile type to register
  47159. * @param constructFunction the function to be called when loading this profile
  47160. */
  47161. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47162. /**
  47163. * Register a fallback to a specific profile.
  47164. * @param profileId the profileId that will receive the fallbacks
  47165. * @param fallbacks A list of fallback profiles
  47166. */
  47167. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47168. /**
  47169. * Will update the list of profiles available in the repository
  47170. * @return a promise that resolves to a map of profiles available online
  47171. */
  47172. static UpdateProfilesList(): Promise<{
  47173. [profile: string]: string;
  47174. }>;
  47175. private static _LoadProfileFromRepository;
  47176. private static _LoadProfilesFromAvailableControllers;
  47177. }
  47178. }
  47179. declare module BABYLON {
  47180. /**
  47181. * Configuration options for the WebXR controller creation
  47182. */
  47183. export interface IWebXRControllerOptions {
  47184. /**
  47185. * Should the controller mesh be animated when a user interacts with it
  47186. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47187. */
  47188. disableMotionControllerAnimation?: boolean;
  47189. /**
  47190. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47191. */
  47192. doNotLoadControllerMesh?: boolean;
  47193. /**
  47194. * Force a specific controller type for this controller.
  47195. * This can be used when creating your own profile or when testing different controllers
  47196. */
  47197. forceControllerProfile?: string;
  47198. /**
  47199. * Defines a rendering group ID for meshes that will be loaded.
  47200. * This is for the default controllers only.
  47201. */
  47202. renderingGroupId?: number;
  47203. }
  47204. /**
  47205. * Represents an XR controller
  47206. */
  47207. export class WebXRInputSource {
  47208. private _scene;
  47209. /** The underlying input source for the controller */
  47210. inputSource: XRInputSource;
  47211. private _options;
  47212. private _tmpVector;
  47213. private _uniqueId;
  47214. /**
  47215. * 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
  47216. */
  47217. grip?: AbstractMesh;
  47218. /**
  47219. * If available, this is the gamepad object related to this controller.
  47220. * Using this object it is possible to get click events and trackpad changes of the
  47221. * webxr controller that is currently being used.
  47222. */
  47223. motionController?: WebXRAbstractMotionController;
  47224. /**
  47225. * Event that fires when the controller is removed/disposed.
  47226. * The object provided as event data is this controller, after associated assets were disposed.
  47227. * uniqueId is still available.
  47228. */
  47229. onDisposeObservable: Observable<WebXRInputSource>;
  47230. /**
  47231. * Will be triggered when the mesh associated with the motion controller is done loading.
  47232. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47233. * A shortened version of controller -> motion controller -> on mesh loaded.
  47234. */
  47235. onMeshLoadedObservable: Observable<AbstractMesh>;
  47236. /**
  47237. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47238. */
  47239. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47240. /**
  47241. * Pointer which can be used to select objects or attach a visible laser to
  47242. */
  47243. pointer: AbstractMesh;
  47244. /**
  47245. * Creates the controller
  47246. * @see https://doc.babylonjs.com/how_to/webxr
  47247. * @param _scene the scene which the controller should be associated to
  47248. * @param inputSource the underlying input source for the controller
  47249. * @param _options options for this controller creation
  47250. */
  47251. constructor(_scene: Scene,
  47252. /** The underlying input source for the controller */
  47253. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47254. /**
  47255. * Get this controllers unique id
  47256. */
  47257. get uniqueId(): string;
  47258. /**
  47259. * Disposes of the object
  47260. */
  47261. dispose(): void;
  47262. /**
  47263. * Gets a world space ray coming from the pointer or grip
  47264. * @param result the resulting ray
  47265. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47266. */
  47267. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47268. /**
  47269. * Updates the controller pose based on the given XRFrame
  47270. * @param xrFrame xr frame to update the pose with
  47271. * @param referenceSpace reference space to use
  47272. */
  47273. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47274. }
  47275. }
  47276. declare module BABYLON {
  47277. /**
  47278. * The schema for initialization options of the XR Input class
  47279. */
  47280. export interface IWebXRInputOptions {
  47281. /**
  47282. * If set to true no model will be automatically loaded
  47283. */
  47284. doNotLoadControllerMeshes?: boolean;
  47285. /**
  47286. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47287. * If not found, the xr input profile data will be used.
  47288. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47289. */
  47290. forceInputProfile?: string;
  47291. /**
  47292. * Do not send a request to the controller repository to load the profile.
  47293. *
  47294. * Instead, use the controllers available in babylon itself.
  47295. */
  47296. disableOnlineControllerRepository?: boolean;
  47297. /**
  47298. * A custom URL for the controllers repository
  47299. */
  47300. customControllersRepositoryURL?: string;
  47301. /**
  47302. * Should the controller model's components not move according to the user input
  47303. */
  47304. disableControllerAnimation?: boolean;
  47305. /**
  47306. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47307. */
  47308. controllerOptions?: IWebXRControllerOptions;
  47309. }
  47310. /**
  47311. * XR input used to track XR inputs such as controllers/rays
  47312. */
  47313. export class WebXRInput implements IDisposable {
  47314. /**
  47315. * the xr session manager for this session
  47316. */
  47317. xrSessionManager: WebXRSessionManager;
  47318. /**
  47319. * the WebXR camera for this session. Mainly used for teleportation
  47320. */
  47321. xrCamera: WebXRCamera;
  47322. private readonly options;
  47323. /**
  47324. * XR controllers being tracked
  47325. */
  47326. controllers: Array<WebXRInputSource>;
  47327. private _frameObserver;
  47328. private _sessionEndedObserver;
  47329. private _sessionInitObserver;
  47330. /**
  47331. * Event when a controller has been connected/added
  47332. */
  47333. onControllerAddedObservable: Observable<WebXRInputSource>;
  47334. /**
  47335. * Event when a controller has been removed/disconnected
  47336. */
  47337. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47338. /**
  47339. * Initializes the WebXRInput
  47340. * @param xrSessionManager the xr session manager for this session
  47341. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47342. * @param options = initialization options for this xr input
  47343. */
  47344. constructor(
  47345. /**
  47346. * the xr session manager for this session
  47347. */
  47348. xrSessionManager: WebXRSessionManager,
  47349. /**
  47350. * the WebXR camera for this session. Mainly used for teleportation
  47351. */
  47352. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47353. private _onInputSourcesChange;
  47354. private _addAndRemoveControllers;
  47355. /**
  47356. * Disposes of the object
  47357. */
  47358. dispose(): void;
  47359. }
  47360. }
  47361. declare module BABYLON {
  47362. /**
  47363. * This is the base class for all WebXR features.
  47364. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47365. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47366. */
  47367. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47368. protected _xrSessionManager: WebXRSessionManager;
  47369. private _attached;
  47370. private _removeOnDetach;
  47371. /**
  47372. * Should auto-attach be disabled?
  47373. */
  47374. disableAutoAttach: boolean;
  47375. /**
  47376. * Construct a new (abstract) WebXR feature
  47377. * @param _xrSessionManager the xr session manager for this feature
  47378. */
  47379. constructor(_xrSessionManager: WebXRSessionManager);
  47380. /**
  47381. * Is this feature attached
  47382. */
  47383. get attached(): boolean;
  47384. /**
  47385. * attach this feature
  47386. *
  47387. * @param force should attachment be forced (even when already attached)
  47388. * @returns true if successful, false is failed or already attached
  47389. */
  47390. attach(force?: boolean): boolean;
  47391. /**
  47392. * detach this feature.
  47393. *
  47394. * @returns true if successful, false if failed or already detached
  47395. */
  47396. detach(): boolean;
  47397. /**
  47398. * Dispose this feature and all of the resources attached
  47399. */
  47400. dispose(): void;
  47401. /**
  47402. * This is used to register callbacks that will automatically be removed when detach is called.
  47403. * @param observable the observable to which the observer will be attached
  47404. * @param callback the callback to register
  47405. */
  47406. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47407. /**
  47408. * Code in this function will be executed on each xrFrame received from the browser.
  47409. * This function will not execute after the feature is detached.
  47410. * @param _xrFrame the current frame
  47411. */
  47412. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47413. }
  47414. }
  47415. declare module BABYLON {
  47416. /**
  47417. * Renders a layer on top of an existing scene
  47418. */
  47419. export class UtilityLayerRenderer implements IDisposable {
  47420. /** the original scene that will be rendered on top of */
  47421. originalScene: Scene;
  47422. private _pointerCaptures;
  47423. private _lastPointerEvents;
  47424. private static _DefaultUtilityLayer;
  47425. private static _DefaultKeepDepthUtilityLayer;
  47426. private _sharedGizmoLight;
  47427. private _renderCamera;
  47428. /**
  47429. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47430. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47431. * @returns the camera that is used when rendering the utility layer
  47432. */
  47433. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47434. /**
  47435. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47436. * @param cam the camera that should be used when rendering the utility layer
  47437. */
  47438. setRenderCamera(cam: Nullable<Camera>): void;
  47439. /**
  47440. * @hidden
  47441. * Light which used by gizmos to get light shading
  47442. */
  47443. _getSharedGizmoLight(): HemisphericLight;
  47444. /**
  47445. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47446. */
  47447. pickUtilitySceneFirst: boolean;
  47448. /**
  47449. * 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)
  47450. */
  47451. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47452. /**
  47453. * 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)
  47454. */
  47455. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47456. /**
  47457. * The scene that is rendered on top of the original scene
  47458. */
  47459. utilityLayerScene: Scene;
  47460. /**
  47461. * If the utility layer should automatically be rendered on top of existing scene
  47462. */
  47463. shouldRender: boolean;
  47464. /**
  47465. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47466. */
  47467. onlyCheckPointerDownEvents: boolean;
  47468. /**
  47469. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47470. */
  47471. processAllEvents: boolean;
  47472. /**
  47473. * Observable raised when the pointer move from the utility layer scene to the main scene
  47474. */
  47475. onPointerOutObservable: Observable<number>;
  47476. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47477. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47478. private _afterRenderObserver;
  47479. private _sceneDisposeObserver;
  47480. private _originalPointerObserver;
  47481. /**
  47482. * Instantiates a UtilityLayerRenderer
  47483. * @param originalScene the original scene that will be rendered on top of
  47484. * @param handleEvents boolean indicating if the utility layer should handle events
  47485. */
  47486. constructor(
  47487. /** the original scene that will be rendered on top of */
  47488. originalScene: Scene, handleEvents?: boolean);
  47489. private _notifyObservers;
  47490. /**
  47491. * Renders the utility layers scene on top of the original scene
  47492. */
  47493. render(): void;
  47494. /**
  47495. * Disposes of the renderer
  47496. */
  47497. dispose(): void;
  47498. private _updateCamera;
  47499. }
  47500. }
  47501. declare module BABYLON {
  47502. /**
  47503. * Options interface for the pointer selection module
  47504. */
  47505. export interface IWebXRControllerPointerSelectionOptions {
  47506. /**
  47507. * if provided, this scene will be used to render meshes.
  47508. */
  47509. customUtilityLayerScene?: Scene;
  47510. /**
  47511. * 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)
  47512. * If not disabled, the last picked point will be used to execute a pointer up event
  47513. * If disabled, pointer up event will be triggered right after the pointer down event.
  47514. * Used in screen and gaze target ray mode only
  47515. */
  47516. disablePointerUpOnTouchOut: boolean;
  47517. /**
  47518. * For gaze mode (time to select instead of press)
  47519. */
  47520. forceGazeMode: boolean;
  47521. /**
  47522. * 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
  47523. * to start a new countdown to the pointer down event.
  47524. * Defaults to 1.
  47525. */
  47526. gazeModePointerMovedFactor?: number;
  47527. /**
  47528. * Different button type to use instead of the main component
  47529. */
  47530. overrideButtonId?: string;
  47531. /**
  47532. * use this rendering group id for the meshes (optional)
  47533. */
  47534. renderingGroupId?: number;
  47535. /**
  47536. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47537. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47538. * 3000 means 3 seconds between pointing at something and selecting it
  47539. */
  47540. timeToSelect?: number;
  47541. /**
  47542. * Should meshes created here be added to a utility layer or the main scene
  47543. */
  47544. useUtilityLayer?: boolean;
  47545. /**
  47546. * the xr input to use with this pointer selection
  47547. */
  47548. xrInput: WebXRInput;
  47549. }
  47550. /**
  47551. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47552. */
  47553. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47554. private readonly _options;
  47555. private static _idCounter;
  47556. private _attachController;
  47557. private _controllers;
  47558. private _scene;
  47559. private _tmpVectorForPickCompare;
  47560. /**
  47561. * The module's name
  47562. */
  47563. static readonly Name: string;
  47564. /**
  47565. * The (Babylon) version of this module.
  47566. * This is an integer representing the implementation version.
  47567. * This number does not correspond to the WebXR specs version
  47568. */
  47569. static readonly Version: number;
  47570. /**
  47571. * Disable lighting on the laser pointer (so it will always be visible)
  47572. */
  47573. disablePointerLighting: boolean;
  47574. /**
  47575. * Disable lighting on the selection mesh (so it will always be visible)
  47576. */
  47577. disableSelectionMeshLighting: boolean;
  47578. /**
  47579. * Should the laser pointer be displayed
  47580. */
  47581. displayLaserPointer: boolean;
  47582. /**
  47583. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47584. */
  47585. displaySelectionMesh: boolean;
  47586. /**
  47587. * This color will be set to the laser pointer when selection is triggered
  47588. */
  47589. laserPointerPickedColor: Color3;
  47590. /**
  47591. * Default color of the laser pointer
  47592. */
  47593. lasterPointerDefaultColor: Color3;
  47594. /**
  47595. * default color of the selection ring
  47596. */
  47597. selectionMeshDefaultColor: Color3;
  47598. /**
  47599. * This color will be applied to the selection ring when selection is triggered
  47600. */
  47601. selectionMeshPickedColor: Color3;
  47602. /**
  47603. * Optional filter to be used for ray selection. This predicate shares behavior with
  47604. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47605. */
  47606. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47607. /**
  47608. * constructs a new background remover module
  47609. * @param _xrSessionManager the session manager for this module
  47610. * @param _options read-only options to be used in this module
  47611. */
  47612. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47613. /**
  47614. * attach this feature
  47615. * Will usually be called by the features manager
  47616. *
  47617. * @returns true if successful.
  47618. */
  47619. attach(): boolean;
  47620. /**
  47621. * detach this feature.
  47622. * Will usually be called by the features manager
  47623. *
  47624. * @returns true if successful.
  47625. */
  47626. detach(): boolean;
  47627. /**
  47628. * Will get the mesh under a specific pointer.
  47629. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47630. * @param controllerId the controllerId to check
  47631. * @returns The mesh under pointer or null if no mesh is under the pointer
  47632. */
  47633. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47634. /**
  47635. * Get the xr controller that correlates to the pointer id in the pointer event
  47636. *
  47637. * @param id the pointer id to search for
  47638. * @returns the controller that correlates to this id or null if not found
  47639. */
  47640. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47641. protected _onXRFrame(_xrFrame: XRFrame): void;
  47642. private _attachGazeMode;
  47643. private _attachScreenRayMode;
  47644. private _attachTrackedPointerRayMode;
  47645. private _convertNormalToDirectionOfRay;
  47646. private _detachController;
  47647. private _generateNewMeshPair;
  47648. private _pickingMoved;
  47649. private _updatePointerDistance;
  47650. }
  47651. }
  47652. declare module BABYLON {
  47653. /**
  47654. * Button which can be used to enter a different mode of XR
  47655. */
  47656. export class WebXREnterExitUIButton {
  47657. /** button element */
  47658. element: HTMLElement;
  47659. /** XR initialization options for the button */
  47660. sessionMode: XRSessionMode;
  47661. /** Reference space type */
  47662. referenceSpaceType: XRReferenceSpaceType;
  47663. /**
  47664. * Creates a WebXREnterExitUIButton
  47665. * @param element button element
  47666. * @param sessionMode XR initialization session mode
  47667. * @param referenceSpaceType the type of reference space to be used
  47668. */
  47669. constructor(
  47670. /** button element */
  47671. element: HTMLElement,
  47672. /** XR initialization options for the button */
  47673. sessionMode: XRSessionMode,
  47674. /** Reference space type */
  47675. referenceSpaceType: XRReferenceSpaceType);
  47676. /**
  47677. * Extendable function which can be used to update the button's visuals when the state changes
  47678. * @param activeButton the current active button in the UI
  47679. */
  47680. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47681. }
  47682. /**
  47683. * Options to create the webXR UI
  47684. */
  47685. export class WebXREnterExitUIOptions {
  47686. /**
  47687. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47688. */
  47689. customButtons?: Array<WebXREnterExitUIButton>;
  47690. /**
  47691. * A reference space type to use when creating the default button.
  47692. * Default is local-floor
  47693. */
  47694. referenceSpaceType?: XRReferenceSpaceType;
  47695. /**
  47696. * Context to enter xr with
  47697. */
  47698. renderTarget?: Nullable<WebXRRenderTarget>;
  47699. /**
  47700. * A session mode to use when creating the default button.
  47701. * Default is immersive-vr
  47702. */
  47703. sessionMode?: XRSessionMode;
  47704. /**
  47705. * A list of optional features to init the session with
  47706. */
  47707. optionalFeatures?: string[];
  47708. }
  47709. /**
  47710. * UI to allow the user to enter/exit XR mode
  47711. */
  47712. export class WebXREnterExitUI implements IDisposable {
  47713. private scene;
  47714. /** version of the options passed to this UI */
  47715. options: WebXREnterExitUIOptions;
  47716. private _activeButton;
  47717. private _buttons;
  47718. private _overlay;
  47719. /**
  47720. * Fired every time the active button is changed.
  47721. *
  47722. * When xr is entered via a button that launches xr that button will be the callback parameter
  47723. *
  47724. * When exiting xr the callback parameter will be null)
  47725. */
  47726. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  47727. /**
  47728. *
  47729. * @param scene babylon scene object to use
  47730. * @param options (read-only) version of the options passed to this UI
  47731. */
  47732. private constructor();
  47733. /**
  47734. * Creates UI to allow the user to enter/exit XR mode
  47735. * @param scene the scene to add the ui to
  47736. * @param helper the xr experience helper to enter/exit xr with
  47737. * @param options options to configure the UI
  47738. * @returns the created ui
  47739. */
  47740. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  47741. /**
  47742. * Disposes of the XR UI component
  47743. */
  47744. dispose(): void;
  47745. private _updateButtons;
  47746. }
  47747. }
  47748. declare module BABYLON {
  47749. /**
  47750. * Class containing static functions to help procedurally build meshes
  47751. */
  47752. export class LinesBuilder {
  47753. /**
  47754. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47755. * * 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
  47756. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47757. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47758. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47759. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47760. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47761. * * 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
  47762. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47764. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47765. * @param name defines the name of the new line system
  47766. * @param options defines the options used to create the line system
  47767. * @param scene defines the hosting scene
  47768. * @returns a new line system mesh
  47769. */
  47770. static CreateLineSystem(name: string, options: {
  47771. lines: Vector3[][];
  47772. updatable?: boolean;
  47773. instance?: Nullable<LinesMesh>;
  47774. colors?: Nullable<Color4[][]>;
  47775. useVertexAlpha?: boolean;
  47776. }, scene: Nullable<Scene>): LinesMesh;
  47777. /**
  47778. * Creates a line mesh
  47779. * 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
  47780. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47781. * * The parameter `points` is an array successive Vector3
  47782. * * 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
  47783. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47784. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47785. * * When updating an instance, remember that only point positions can change, not the number of points
  47786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47787. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47788. * @param name defines the name of the new line system
  47789. * @param options defines the options used to create the line system
  47790. * @param scene defines the hosting scene
  47791. * @returns a new line mesh
  47792. */
  47793. static CreateLines(name: string, options: {
  47794. points: Vector3[];
  47795. updatable?: boolean;
  47796. instance?: Nullable<LinesMesh>;
  47797. colors?: Color4[];
  47798. useVertexAlpha?: boolean;
  47799. }, scene?: Nullable<Scene>): LinesMesh;
  47800. /**
  47801. * Creates a dashed line mesh
  47802. * * 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
  47803. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47804. * * The parameter `points` is an array successive Vector3
  47805. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47806. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47807. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47808. * * 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
  47809. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47810. * * When updating an instance, remember that only point positions can change, not the number of points
  47811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47812. * @param name defines the name of the mesh
  47813. * @param options defines the options used to create the mesh
  47814. * @param scene defines the hosting scene
  47815. * @returns the dashed line mesh
  47816. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47817. */
  47818. static CreateDashedLines(name: string, options: {
  47819. points: Vector3[];
  47820. dashSize?: number;
  47821. gapSize?: number;
  47822. dashNb?: number;
  47823. updatable?: boolean;
  47824. instance?: LinesMesh;
  47825. useVertexAlpha?: boolean;
  47826. }, scene?: Nullable<Scene>): LinesMesh;
  47827. }
  47828. }
  47829. declare module BABYLON {
  47830. /**
  47831. * The options container for the teleportation module
  47832. */
  47833. export interface IWebXRTeleportationOptions {
  47834. /**
  47835. * if provided, this scene will be used to render meshes.
  47836. */
  47837. customUtilityLayerScene?: Scene;
  47838. /**
  47839. * Values to configure the default target mesh
  47840. */
  47841. defaultTargetMeshOptions?: {
  47842. /**
  47843. * Fill color of the teleportation area
  47844. */
  47845. teleportationFillColor?: string;
  47846. /**
  47847. * Border color for the teleportation area
  47848. */
  47849. teleportationBorderColor?: string;
  47850. /**
  47851. * Disable the mesh's animation sequence
  47852. */
  47853. disableAnimation?: boolean;
  47854. /**
  47855. * Disable lighting on the material or the ring and arrow
  47856. */
  47857. disableLighting?: boolean;
  47858. /**
  47859. * Override the default material of the torus and arrow
  47860. */
  47861. torusArrowMaterial?: Material;
  47862. };
  47863. /**
  47864. * A list of meshes to use as floor meshes.
  47865. * Meshes can be added and removed after initializing the feature using the
  47866. * addFloorMesh and removeFloorMesh functions
  47867. * If empty, rotation will still work
  47868. */
  47869. floorMeshes?: AbstractMesh[];
  47870. /**
  47871. * use this rendering group id for the meshes (optional)
  47872. */
  47873. renderingGroupId?: number;
  47874. /**
  47875. * Should teleportation move only to snap points
  47876. */
  47877. snapPointsOnly?: boolean;
  47878. /**
  47879. * An array of points to which the teleportation will snap to.
  47880. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  47881. */
  47882. snapPositions?: Vector3[];
  47883. /**
  47884. * How close should the teleportation ray be in order to snap to position.
  47885. * Default to 0.8 units (meters)
  47886. */
  47887. snapToPositionRadius?: number;
  47888. /**
  47889. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  47890. * If you want to support rotation, make sure your mesh has a direction indicator.
  47891. *
  47892. * When left untouched, the default mesh will be initialized.
  47893. */
  47894. teleportationTargetMesh?: AbstractMesh;
  47895. /**
  47896. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  47897. */
  47898. timeToTeleport?: number;
  47899. /**
  47900. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  47901. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  47902. */
  47903. useMainComponentOnly?: boolean;
  47904. /**
  47905. * Should meshes created here be added to a utility layer or the main scene
  47906. */
  47907. useUtilityLayer?: boolean;
  47908. /**
  47909. * Babylon XR Input class for controller
  47910. */
  47911. xrInput: WebXRInput;
  47912. }
  47913. /**
  47914. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47915. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47916. * the input of the attached controllers.
  47917. */
  47918. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47919. private _options;
  47920. private _controllers;
  47921. private _currentTeleportationControllerId;
  47922. private _floorMeshes;
  47923. private _quadraticBezierCurve;
  47924. private _selectionFeature;
  47925. private _snapToPositions;
  47926. private _snappedToPoint;
  47927. private _teleportationRingMaterial?;
  47928. private _tmpRay;
  47929. private _tmpVector;
  47930. /**
  47931. * The module's name
  47932. */
  47933. static readonly Name: string;
  47934. /**
  47935. * The (Babylon) version of this module.
  47936. * This is an integer representing the implementation version.
  47937. * This number does not correspond to the webxr specs version
  47938. */
  47939. static readonly Version: number;
  47940. /**
  47941. * Is movement backwards enabled
  47942. */
  47943. backwardsMovementEnabled: boolean;
  47944. /**
  47945. * Distance to travel when moving backwards
  47946. */
  47947. backwardsTeleportationDistance: number;
  47948. /**
  47949. * The distance from the user to the inspection point in the direction of the controller
  47950. * A higher number will allow the user to move further
  47951. * defaults to 5 (meters, in xr units)
  47952. */
  47953. parabolicCheckRadius: number;
  47954. /**
  47955. * Should the module support parabolic ray on top of direct ray
  47956. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  47957. * Very helpful when moving between floors / different heights
  47958. */
  47959. parabolicRayEnabled: boolean;
  47960. /**
  47961. * How much rotation should be applied when rotating right and left
  47962. */
  47963. rotationAngle: number;
  47964. /**
  47965. * Is rotation enabled when moving forward?
  47966. * Disabling this feature will prevent the user from deciding the direction when teleporting
  47967. */
  47968. rotationEnabled: boolean;
  47969. /**
  47970. * constructs a new anchor system
  47971. * @param _xrSessionManager an instance of WebXRSessionManager
  47972. * @param _options configuration object for this feature
  47973. */
  47974. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  47975. /**
  47976. * Get the snapPointsOnly flag
  47977. */
  47978. get snapPointsOnly(): boolean;
  47979. /**
  47980. * Sets the snapPointsOnly flag
  47981. * @param snapToPoints should teleportation be exclusively to snap points
  47982. */
  47983. set snapPointsOnly(snapToPoints: boolean);
  47984. /**
  47985. * Add a new mesh to the floor meshes array
  47986. * @param mesh the mesh to use as floor mesh
  47987. */
  47988. addFloorMesh(mesh: AbstractMesh): void;
  47989. /**
  47990. * Add a new snap-to point to fix teleportation to this position
  47991. * @param newSnapPoint The new Snap-To point
  47992. */
  47993. addSnapPoint(newSnapPoint: Vector3): void;
  47994. attach(): boolean;
  47995. detach(): boolean;
  47996. dispose(): void;
  47997. /**
  47998. * Remove a mesh from the floor meshes array
  47999. * @param mesh the mesh to remove
  48000. */
  48001. removeFloorMesh(mesh: AbstractMesh): void;
  48002. /**
  48003. * Remove a mesh from the floor meshes array using its name
  48004. * @param name the mesh name to remove
  48005. */
  48006. removeFloorMeshByName(name: string): void;
  48007. /**
  48008. * 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
  48009. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48010. * @returns was the point found and removed or not
  48011. */
  48012. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48013. /**
  48014. * This function sets a selection feature that will be disabled when
  48015. * the forward ray is shown and will be reattached when hidden.
  48016. * This is used to remove the selection rays when moving.
  48017. * @param selectionFeature the feature to disable when forward movement is enabled
  48018. */
  48019. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48020. protected _onXRFrame(_xrFrame: XRFrame): void;
  48021. private _attachController;
  48022. private _createDefaultTargetMesh;
  48023. private _detachController;
  48024. private _findClosestSnapPointWithRadius;
  48025. private _setTargetMeshPosition;
  48026. private _setTargetMeshVisibility;
  48027. private _showParabolicPath;
  48028. private _teleportForward;
  48029. }
  48030. }
  48031. declare module BABYLON {
  48032. /**
  48033. * Options for the default xr helper
  48034. */
  48035. export class WebXRDefaultExperienceOptions {
  48036. /**
  48037. * Enable or disable default UI to enter XR
  48038. */
  48039. disableDefaultUI?: boolean;
  48040. /**
  48041. * Should teleportation not initialize. defaults to false.
  48042. */
  48043. disableTeleportation?: boolean;
  48044. /**
  48045. * Floor meshes that will be used for teleport
  48046. */
  48047. floorMeshes?: Array<AbstractMesh>;
  48048. /**
  48049. * If set to true, the first frame will not be used to reset position
  48050. * The first frame is mainly used when copying transformation from the old camera
  48051. * Mainly used in AR
  48052. */
  48053. ignoreNativeCameraTransformation?: boolean;
  48054. /**
  48055. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48056. */
  48057. inputOptions?: IWebXRInputOptions;
  48058. /**
  48059. * optional configuration for the output canvas
  48060. */
  48061. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48062. /**
  48063. * optional UI options. This can be used among other to change session mode and reference space type
  48064. */
  48065. uiOptions?: WebXREnterExitUIOptions;
  48066. /**
  48067. * When loading teleportation and pointer select, use stable versions instead of latest.
  48068. */
  48069. useStablePlugins?: boolean;
  48070. /**
  48071. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48072. */
  48073. renderingGroupId?: number;
  48074. /**
  48075. * A list of optional features to init the session with
  48076. * If set to true, all features we support will be added
  48077. */
  48078. optionalFeatures?: boolean | string[];
  48079. }
  48080. /**
  48081. * Default experience which provides a similar setup to the previous webVRExperience
  48082. */
  48083. export class WebXRDefaultExperience {
  48084. /**
  48085. * Base experience
  48086. */
  48087. baseExperience: WebXRExperienceHelper;
  48088. /**
  48089. * Enables ui for entering/exiting xr
  48090. */
  48091. enterExitUI: WebXREnterExitUI;
  48092. /**
  48093. * Input experience extension
  48094. */
  48095. input: WebXRInput;
  48096. /**
  48097. * Enables laser pointer and selection
  48098. */
  48099. pointerSelection: WebXRControllerPointerSelection;
  48100. /**
  48101. * Default target xr should render to
  48102. */
  48103. renderTarget: WebXRRenderTarget;
  48104. /**
  48105. * Enables teleportation
  48106. */
  48107. teleportation: WebXRMotionControllerTeleportation;
  48108. private constructor();
  48109. /**
  48110. * Creates the default xr experience
  48111. * @param scene scene
  48112. * @param options options for basic configuration
  48113. * @returns resulting WebXRDefaultExperience
  48114. */
  48115. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48116. /**
  48117. * DIsposes of the experience helper
  48118. */
  48119. dispose(): void;
  48120. }
  48121. }
  48122. declare module BABYLON {
  48123. /**
  48124. * Options to modify the vr teleportation behavior.
  48125. */
  48126. export interface VRTeleportationOptions {
  48127. /**
  48128. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48129. */
  48130. floorMeshName?: string;
  48131. /**
  48132. * A list of meshes to be used as the teleportation floor. (default: empty)
  48133. */
  48134. floorMeshes?: Mesh[];
  48135. /**
  48136. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48137. */
  48138. teleportationMode?: number;
  48139. /**
  48140. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48141. */
  48142. teleportationTime?: number;
  48143. /**
  48144. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48145. */
  48146. teleportationSpeed?: number;
  48147. /**
  48148. * The easing function used in the animation or null for Linear. (default CircleEase)
  48149. */
  48150. easingFunction?: EasingFunction;
  48151. }
  48152. /**
  48153. * Options to modify the vr experience helper's behavior.
  48154. */
  48155. export interface VRExperienceHelperOptions extends WebVROptions {
  48156. /**
  48157. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48158. */
  48159. createDeviceOrientationCamera?: boolean;
  48160. /**
  48161. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48162. */
  48163. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48164. /**
  48165. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48166. */
  48167. laserToggle?: boolean;
  48168. /**
  48169. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48170. */
  48171. floorMeshes?: Mesh[];
  48172. /**
  48173. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48174. */
  48175. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48176. /**
  48177. * Defines if WebXR should be used instead of WebVR (if available)
  48178. */
  48179. useXR?: boolean;
  48180. }
  48181. /**
  48182. * Event containing information after VR has been entered
  48183. */
  48184. export class OnAfterEnteringVRObservableEvent {
  48185. /**
  48186. * If entering vr was successful
  48187. */
  48188. success: boolean;
  48189. }
  48190. /**
  48191. * Helps to quickly add VR support to an existing scene.
  48192. * See http://doc.babylonjs.com/how_to/webvr_helper
  48193. */
  48194. export class VRExperienceHelper {
  48195. /** Options to modify the vr experience helper's behavior. */
  48196. webVROptions: VRExperienceHelperOptions;
  48197. private _scene;
  48198. private _position;
  48199. private _btnVR;
  48200. private _btnVRDisplayed;
  48201. private _webVRsupported;
  48202. private _webVRready;
  48203. private _webVRrequesting;
  48204. private _webVRpresenting;
  48205. private _hasEnteredVR;
  48206. private _fullscreenVRpresenting;
  48207. private _inputElement;
  48208. private _webVRCamera;
  48209. private _vrDeviceOrientationCamera;
  48210. private _deviceOrientationCamera;
  48211. private _existingCamera;
  48212. private _onKeyDown;
  48213. private _onVrDisplayPresentChange;
  48214. private _onVRDisplayChanged;
  48215. private _onVRRequestPresentStart;
  48216. private _onVRRequestPresentComplete;
  48217. /**
  48218. * 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)
  48219. */
  48220. enableGazeEvenWhenNoPointerLock: boolean;
  48221. /**
  48222. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48223. */
  48224. exitVROnDoubleTap: boolean;
  48225. /**
  48226. * Observable raised right before entering VR.
  48227. */
  48228. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48229. /**
  48230. * Observable raised when entering VR has completed.
  48231. */
  48232. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48233. /**
  48234. * Observable raised when exiting VR.
  48235. */
  48236. onExitingVRObservable: Observable<VRExperienceHelper>;
  48237. /**
  48238. * Observable raised when controller mesh is loaded.
  48239. */
  48240. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48241. /** Return this.onEnteringVRObservable
  48242. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48243. */
  48244. get onEnteringVR(): Observable<VRExperienceHelper>;
  48245. /** Return this.onExitingVRObservable
  48246. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48247. */
  48248. get onExitingVR(): Observable<VRExperienceHelper>;
  48249. /** Return this.onControllerMeshLoadedObservable
  48250. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48251. */
  48252. get onControllerMeshLoaded(): Observable<WebVRController>;
  48253. private _rayLength;
  48254. private _useCustomVRButton;
  48255. private _teleportationRequested;
  48256. private _teleportActive;
  48257. private _floorMeshName;
  48258. private _floorMeshesCollection;
  48259. private _teleportationMode;
  48260. private _teleportationTime;
  48261. private _teleportationSpeed;
  48262. private _teleportationEasing;
  48263. private _rotationAllowed;
  48264. private _teleportBackwardsVector;
  48265. private _teleportationTarget;
  48266. private _isDefaultTeleportationTarget;
  48267. private _postProcessMove;
  48268. private _teleportationFillColor;
  48269. private _teleportationBorderColor;
  48270. private _rotationAngle;
  48271. private _haloCenter;
  48272. private _cameraGazer;
  48273. private _padSensibilityUp;
  48274. private _padSensibilityDown;
  48275. private _leftController;
  48276. private _rightController;
  48277. private _gazeColor;
  48278. private _laserColor;
  48279. private _pickedLaserColor;
  48280. private _pickedGazeColor;
  48281. /**
  48282. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48283. */
  48284. onNewMeshSelected: Observable<AbstractMesh>;
  48285. /**
  48286. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48287. * This observable will provide the mesh and the controller used to select the mesh
  48288. */
  48289. onMeshSelectedWithController: Observable<{
  48290. mesh: AbstractMesh;
  48291. controller: WebVRController;
  48292. }>;
  48293. /**
  48294. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48295. */
  48296. onNewMeshPicked: Observable<PickingInfo>;
  48297. private _circleEase;
  48298. /**
  48299. * Observable raised before camera teleportation
  48300. */
  48301. onBeforeCameraTeleport: Observable<Vector3>;
  48302. /**
  48303. * Observable raised after camera teleportation
  48304. */
  48305. onAfterCameraTeleport: Observable<Vector3>;
  48306. /**
  48307. * Observable raised when current selected mesh gets unselected
  48308. */
  48309. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48310. private _raySelectionPredicate;
  48311. /**
  48312. * To be optionaly changed by user to define custom ray selection
  48313. */
  48314. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48315. /**
  48316. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48317. */
  48318. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48319. /**
  48320. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48321. */
  48322. teleportationEnabled: boolean;
  48323. private _defaultHeight;
  48324. private _teleportationInitialized;
  48325. private _interactionsEnabled;
  48326. private _interactionsRequested;
  48327. private _displayGaze;
  48328. private _displayLaserPointer;
  48329. /**
  48330. * The mesh used to display where the user is going to teleport.
  48331. */
  48332. get teleportationTarget(): Mesh;
  48333. /**
  48334. * Sets the mesh to be used to display where the user is going to teleport.
  48335. */
  48336. set teleportationTarget(value: Mesh);
  48337. /**
  48338. * 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
  48339. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48340. * See http://doc.babylonjs.com/resources/baking_transformations
  48341. */
  48342. get gazeTrackerMesh(): Mesh;
  48343. set gazeTrackerMesh(value: Mesh);
  48344. /**
  48345. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48346. */
  48347. updateGazeTrackerScale: boolean;
  48348. /**
  48349. * If the gaze trackers color should be updated when selecting meshes
  48350. */
  48351. updateGazeTrackerColor: boolean;
  48352. /**
  48353. * If the controller laser color should be updated when selecting meshes
  48354. */
  48355. updateControllerLaserColor: boolean;
  48356. /**
  48357. * The gaze tracking mesh corresponding to the left controller
  48358. */
  48359. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48360. /**
  48361. * The gaze tracking mesh corresponding to the right controller
  48362. */
  48363. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48364. /**
  48365. * If the ray of the gaze should be displayed.
  48366. */
  48367. get displayGaze(): boolean;
  48368. /**
  48369. * Sets if the ray of the gaze should be displayed.
  48370. */
  48371. set displayGaze(value: boolean);
  48372. /**
  48373. * If the ray of the LaserPointer should be displayed.
  48374. */
  48375. get displayLaserPointer(): boolean;
  48376. /**
  48377. * Sets if the ray of the LaserPointer should be displayed.
  48378. */
  48379. set displayLaserPointer(value: boolean);
  48380. /**
  48381. * The deviceOrientationCamera used as the camera when not in VR.
  48382. */
  48383. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48384. /**
  48385. * Based on the current WebVR support, returns the current VR camera used.
  48386. */
  48387. get currentVRCamera(): Nullable<Camera>;
  48388. /**
  48389. * The webVRCamera which is used when in VR.
  48390. */
  48391. get webVRCamera(): WebVRFreeCamera;
  48392. /**
  48393. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48394. */
  48395. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48396. /**
  48397. * The html button that is used to trigger entering into VR.
  48398. */
  48399. get vrButton(): Nullable<HTMLButtonElement>;
  48400. private get _teleportationRequestInitiated();
  48401. /**
  48402. * Defines whether or not Pointer lock should be requested when switching to
  48403. * full screen.
  48404. */
  48405. requestPointerLockOnFullScreen: boolean;
  48406. /**
  48407. * If asking to force XR, this will be populated with the default xr experience
  48408. */
  48409. xr: WebXRDefaultExperience;
  48410. /**
  48411. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48412. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48413. */
  48414. xrTestDone: boolean;
  48415. /**
  48416. * Instantiates a VRExperienceHelper.
  48417. * Helps to quickly add VR support to an existing scene.
  48418. * @param scene The scene the VRExperienceHelper belongs to.
  48419. * @param webVROptions Options to modify the vr experience helper's behavior.
  48420. */
  48421. constructor(scene: Scene,
  48422. /** Options to modify the vr experience helper's behavior. */
  48423. webVROptions?: VRExperienceHelperOptions);
  48424. private completeVRInit;
  48425. private _onDefaultMeshLoaded;
  48426. private _onResize;
  48427. private _onFullscreenChange;
  48428. /**
  48429. * Gets a value indicating if we are currently in VR mode.
  48430. */
  48431. get isInVRMode(): boolean;
  48432. private onVrDisplayPresentChange;
  48433. private onVRDisplayChanged;
  48434. private moveButtonToBottomRight;
  48435. private displayVRButton;
  48436. private updateButtonVisibility;
  48437. private _cachedAngularSensibility;
  48438. /**
  48439. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48440. * Otherwise, will use the fullscreen API.
  48441. */
  48442. enterVR(): void;
  48443. /**
  48444. * Attempt to exit VR, or fullscreen.
  48445. */
  48446. exitVR(): void;
  48447. /**
  48448. * The position of the vr experience helper.
  48449. */
  48450. get position(): Vector3;
  48451. /**
  48452. * Sets the position of the vr experience helper.
  48453. */
  48454. set position(value: Vector3);
  48455. /**
  48456. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48457. */
  48458. enableInteractions(): void;
  48459. private get _noControllerIsActive();
  48460. private beforeRender;
  48461. private _isTeleportationFloor;
  48462. /**
  48463. * Adds a floor mesh to be used for teleportation.
  48464. * @param floorMesh the mesh to be used for teleportation.
  48465. */
  48466. addFloorMesh(floorMesh: Mesh): void;
  48467. /**
  48468. * Removes a floor mesh from being used for teleportation.
  48469. * @param floorMesh the mesh to be removed.
  48470. */
  48471. removeFloorMesh(floorMesh: Mesh): void;
  48472. /**
  48473. * Enables interactions and teleportation using the VR controllers and gaze.
  48474. * @param vrTeleportationOptions options to modify teleportation behavior.
  48475. */
  48476. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48477. private _onNewGamepadConnected;
  48478. private _tryEnableInteractionOnController;
  48479. private _onNewGamepadDisconnected;
  48480. private _enableInteractionOnController;
  48481. private _checkTeleportWithRay;
  48482. private _checkRotate;
  48483. private _checkTeleportBackwards;
  48484. private _enableTeleportationOnController;
  48485. private _createTeleportationCircles;
  48486. private _displayTeleportationTarget;
  48487. private _hideTeleportationTarget;
  48488. private _rotateCamera;
  48489. private _moveTeleportationSelectorTo;
  48490. private _workingVector;
  48491. private _workingQuaternion;
  48492. private _workingMatrix;
  48493. /**
  48494. * Time Constant Teleportation Mode
  48495. */
  48496. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48497. /**
  48498. * Speed Constant Teleportation Mode
  48499. */
  48500. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48501. /**
  48502. * Teleports the users feet to the desired location
  48503. * @param location The location where the user's feet should be placed
  48504. */
  48505. teleportCamera(location: Vector3): void;
  48506. private _convertNormalToDirectionOfRay;
  48507. private _castRayAndSelectObject;
  48508. private _notifySelectedMeshUnselected;
  48509. /**
  48510. * Permanently set new colors for the laser pointer
  48511. * @param color the new laser color
  48512. * @param pickedColor the new laser color when picked mesh detected
  48513. */
  48514. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48515. /**
  48516. * Set lighting enabled / disabled on the laser pointer of both controllers
  48517. * @param enabled should the lighting be enabled on the laser pointer
  48518. */
  48519. setLaserLightingState(enabled?: boolean): void;
  48520. /**
  48521. * Permanently set new colors for the gaze pointer
  48522. * @param color the new gaze color
  48523. * @param pickedColor the new gaze color when picked mesh detected
  48524. */
  48525. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48526. /**
  48527. * Sets the color of the laser ray from the vr controllers.
  48528. * @param color new color for the ray.
  48529. */
  48530. changeLaserColor(color: Color3): void;
  48531. /**
  48532. * Sets the color of the ray from the vr headsets gaze.
  48533. * @param color new color for the ray.
  48534. */
  48535. changeGazeColor(color: Color3): void;
  48536. /**
  48537. * Exits VR and disposes of the vr experience helper
  48538. */
  48539. dispose(): void;
  48540. /**
  48541. * Gets the name of the VRExperienceHelper class
  48542. * @returns "VRExperienceHelper"
  48543. */
  48544. getClassName(): string;
  48545. }
  48546. }
  48547. declare module BABYLON {
  48548. /**
  48549. * Contains an array of blocks representing the octree
  48550. */
  48551. export interface IOctreeContainer<T> {
  48552. /**
  48553. * Blocks within the octree
  48554. */
  48555. blocks: Array<OctreeBlock<T>>;
  48556. }
  48557. /**
  48558. * Class used to store a cell in an octree
  48559. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48560. */
  48561. export class OctreeBlock<T> {
  48562. /**
  48563. * Gets the content of the current block
  48564. */
  48565. entries: T[];
  48566. /**
  48567. * Gets the list of block children
  48568. */
  48569. blocks: Array<OctreeBlock<T>>;
  48570. private _depth;
  48571. private _maxDepth;
  48572. private _capacity;
  48573. private _minPoint;
  48574. private _maxPoint;
  48575. private _boundingVectors;
  48576. private _creationFunc;
  48577. /**
  48578. * Creates a new block
  48579. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  48580. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  48581. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48582. * @param depth defines the current depth of this block in the octree
  48583. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  48584. * @param creationFunc defines a callback to call when an element is added to the block
  48585. */
  48586. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  48587. /**
  48588. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48589. */
  48590. get capacity(): number;
  48591. /**
  48592. * Gets the minimum vector (in world space) of the block's bounding box
  48593. */
  48594. get minPoint(): Vector3;
  48595. /**
  48596. * Gets the maximum vector (in world space) of the block's bounding box
  48597. */
  48598. get maxPoint(): Vector3;
  48599. /**
  48600. * Add a new element to this block
  48601. * @param entry defines the element to add
  48602. */
  48603. addEntry(entry: T): void;
  48604. /**
  48605. * Remove an element from this block
  48606. * @param entry defines the element to remove
  48607. */
  48608. removeEntry(entry: T): void;
  48609. /**
  48610. * Add an array of elements to this block
  48611. * @param entries defines the array of elements to add
  48612. */
  48613. addEntries(entries: T[]): void;
  48614. /**
  48615. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  48616. * @param frustumPlanes defines the frustum planes to test
  48617. * @param selection defines the array to store current content if selection is positive
  48618. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48619. */
  48620. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48621. /**
  48622. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  48623. * @param sphereCenter defines the bounding sphere center
  48624. * @param sphereRadius defines the bounding sphere radius
  48625. * @param selection defines the array to store current content if selection is positive
  48626. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48627. */
  48628. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48629. /**
  48630. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  48631. * @param ray defines the ray to test with
  48632. * @param selection defines the array to store current content if selection is positive
  48633. */
  48634. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  48635. /**
  48636. * Subdivide the content into child blocks (this block will then be empty)
  48637. */
  48638. createInnerBlocks(): void;
  48639. /**
  48640. * @hidden
  48641. */
  48642. 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;
  48643. }
  48644. }
  48645. declare module BABYLON {
  48646. /**
  48647. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  48648. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48649. */
  48650. export class Octree<T> {
  48651. /** 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.) */
  48652. maxDepth: number;
  48653. /**
  48654. * Blocks within the octree containing objects
  48655. */
  48656. blocks: Array<OctreeBlock<T>>;
  48657. /**
  48658. * Content stored in the octree
  48659. */
  48660. dynamicContent: T[];
  48661. private _maxBlockCapacity;
  48662. private _selectionContent;
  48663. private _creationFunc;
  48664. /**
  48665. * Creates a octree
  48666. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48667. * @param creationFunc function to be used to instatiate the octree
  48668. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  48669. * @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.)
  48670. */
  48671. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  48672. /** 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.) */
  48673. maxDepth?: number);
  48674. /**
  48675. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  48676. * @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);
  48677. * @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);
  48678. * @param entries meshes to be added to the octree blocks
  48679. */
  48680. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  48681. /**
  48682. * Adds a mesh to the octree
  48683. * @param entry Mesh to add to the octree
  48684. */
  48685. addMesh(entry: T): void;
  48686. /**
  48687. * Remove an element from the octree
  48688. * @param entry defines the element to remove
  48689. */
  48690. removeMesh(entry: T): void;
  48691. /**
  48692. * Selects an array of meshes within the frustum
  48693. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  48694. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  48695. * @returns array of meshes within the frustum
  48696. */
  48697. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  48698. /**
  48699. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  48700. * @param sphereCenter defines the bounding sphere center
  48701. * @param sphereRadius defines the bounding sphere radius
  48702. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48703. * @returns an array of objects that intersect the sphere
  48704. */
  48705. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  48706. /**
  48707. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  48708. * @param ray defines the ray to test with
  48709. * @returns array of intersected objects
  48710. */
  48711. intersectsRay(ray: Ray): SmartArray<T>;
  48712. /**
  48713. * Adds a mesh into the octree block if it intersects the block
  48714. */
  48715. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  48716. /**
  48717. * Adds a submesh into the octree block if it intersects the block
  48718. */
  48719. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  48720. }
  48721. }
  48722. declare module BABYLON {
  48723. interface Scene {
  48724. /**
  48725. * @hidden
  48726. * Backing Filed
  48727. */
  48728. _selectionOctree: Octree<AbstractMesh>;
  48729. /**
  48730. * Gets the octree used to boost mesh selection (picking)
  48731. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48732. */
  48733. selectionOctree: Octree<AbstractMesh>;
  48734. /**
  48735. * Creates or updates the octree used to boost selection (picking)
  48736. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48737. * @param maxCapacity defines the maximum capacity per leaf
  48738. * @param maxDepth defines the maximum depth of the octree
  48739. * @returns an octree of AbstractMesh
  48740. */
  48741. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  48742. }
  48743. interface AbstractMesh {
  48744. /**
  48745. * @hidden
  48746. * Backing Field
  48747. */
  48748. _submeshesOctree: Octree<SubMesh>;
  48749. /**
  48750. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  48751. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  48752. * @param maxCapacity defines the maximum size of each block (64 by default)
  48753. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  48754. * @returns the new octree
  48755. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  48756. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48757. */
  48758. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  48759. }
  48760. /**
  48761. * Defines the octree scene component responsible to manage any octrees
  48762. * in a given scene.
  48763. */
  48764. export class OctreeSceneComponent {
  48765. /**
  48766. * The component name help to identify the component in the list of scene components.
  48767. */
  48768. readonly name: string;
  48769. /**
  48770. * The scene the component belongs to.
  48771. */
  48772. scene: Scene;
  48773. /**
  48774. * Indicates if the meshes have been checked to make sure they are isEnabled()
  48775. */
  48776. readonly checksIsEnabled: boolean;
  48777. /**
  48778. * Creates a new instance of the component for the given scene
  48779. * @param scene Defines the scene to register the component in
  48780. */
  48781. constructor(scene: Scene);
  48782. /**
  48783. * Registers the component in a given scene
  48784. */
  48785. register(): void;
  48786. /**
  48787. * Return the list of active meshes
  48788. * @returns the list of active meshes
  48789. */
  48790. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48791. /**
  48792. * Return the list of active sub meshes
  48793. * @param mesh The mesh to get the candidates sub meshes from
  48794. * @returns the list of active sub meshes
  48795. */
  48796. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48797. private _tempRay;
  48798. /**
  48799. * Return the list of sub meshes intersecting with a given local ray
  48800. * @param mesh defines the mesh to find the submesh for
  48801. * @param localRay defines the ray in local space
  48802. * @returns the list of intersecting sub meshes
  48803. */
  48804. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  48805. /**
  48806. * Return the list of sub meshes colliding with a collider
  48807. * @param mesh defines the mesh to find the submesh for
  48808. * @param collider defines the collider to evaluate the collision against
  48809. * @returns the list of colliding sub meshes
  48810. */
  48811. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  48812. /**
  48813. * Rebuilds the elements related to this component in case of
  48814. * context lost for instance.
  48815. */
  48816. rebuild(): void;
  48817. /**
  48818. * Disposes the component and the associated ressources.
  48819. */
  48820. dispose(): void;
  48821. }
  48822. }
  48823. declare module BABYLON {
  48824. /**
  48825. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48826. */
  48827. export class Gizmo implements IDisposable {
  48828. /** The utility layer the gizmo will be added to */
  48829. gizmoLayer: UtilityLayerRenderer;
  48830. /**
  48831. * The root mesh of the gizmo
  48832. */
  48833. _rootMesh: Mesh;
  48834. private _attachedMesh;
  48835. /**
  48836. * Ratio for the scale of the gizmo (Default: 1)
  48837. */
  48838. scaleRatio: number;
  48839. /**
  48840. * If a custom mesh has been set (Default: false)
  48841. */
  48842. protected _customMeshSet: boolean;
  48843. /**
  48844. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48845. * * When set, interactions will be enabled
  48846. */
  48847. get attachedMesh(): Nullable<AbstractMesh>;
  48848. set attachedMesh(value: Nullable<AbstractMesh>);
  48849. /**
  48850. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48851. * @param mesh The mesh to replace the default mesh of the gizmo
  48852. */
  48853. setCustomMesh(mesh: Mesh): void;
  48854. /**
  48855. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48856. */
  48857. updateGizmoRotationToMatchAttachedMesh: boolean;
  48858. /**
  48859. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48860. */
  48861. updateGizmoPositionToMatchAttachedMesh: boolean;
  48862. /**
  48863. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48864. */
  48865. updateScale: boolean;
  48866. protected _interactionsEnabled: boolean;
  48867. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48868. private _beforeRenderObserver;
  48869. private _tempVector;
  48870. /**
  48871. * Creates a gizmo
  48872. * @param gizmoLayer The utility layer the gizmo will be added to
  48873. */
  48874. constructor(
  48875. /** The utility layer the gizmo will be added to */
  48876. gizmoLayer?: UtilityLayerRenderer);
  48877. /**
  48878. * Updates the gizmo to match the attached mesh's position/rotation
  48879. */
  48880. protected _update(): void;
  48881. /**
  48882. * Disposes of the gizmo
  48883. */
  48884. dispose(): void;
  48885. }
  48886. }
  48887. declare module BABYLON {
  48888. /**
  48889. * Single plane drag gizmo
  48890. */
  48891. export class PlaneDragGizmo extends Gizmo {
  48892. /**
  48893. * Drag behavior responsible for the gizmos dragging interactions
  48894. */
  48895. dragBehavior: PointerDragBehavior;
  48896. private _pointerObserver;
  48897. /**
  48898. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48899. */
  48900. snapDistance: number;
  48901. /**
  48902. * Event that fires each time the gizmo snaps to a new location.
  48903. * * snapDistance is the the change in distance
  48904. */
  48905. onSnapObservable: Observable<{
  48906. snapDistance: number;
  48907. }>;
  48908. private _plane;
  48909. private _coloredMaterial;
  48910. private _hoverMaterial;
  48911. private _isEnabled;
  48912. private _parent;
  48913. /** @hidden */
  48914. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48915. /** @hidden */
  48916. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48917. /**
  48918. * Creates a PlaneDragGizmo
  48919. * @param gizmoLayer The utility layer the gizmo will be added to
  48920. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48921. * @param color The color of the gizmo
  48922. */
  48923. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48924. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48925. /**
  48926. * If the gizmo is enabled
  48927. */
  48928. set isEnabled(value: boolean);
  48929. get isEnabled(): boolean;
  48930. /**
  48931. * Disposes of the gizmo
  48932. */
  48933. dispose(): void;
  48934. }
  48935. }
  48936. declare module BABYLON {
  48937. /**
  48938. * Gizmo that enables dragging a mesh along 3 axis
  48939. */
  48940. export class PositionGizmo extends Gizmo {
  48941. /**
  48942. * Internal gizmo used for interactions on the x axis
  48943. */
  48944. xGizmo: AxisDragGizmo;
  48945. /**
  48946. * Internal gizmo used for interactions on the y axis
  48947. */
  48948. yGizmo: AxisDragGizmo;
  48949. /**
  48950. * Internal gizmo used for interactions on the z axis
  48951. */
  48952. zGizmo: AxisDragGizmo;
  48953. /**
  48954. * Internal gizmo used for interactions on the yz plane
  48955. */
  48956. xPlaneGizmo: PlaneDragGizmo;
  48957. /**
  48958. * Internal gizmo used for interactions on the xz plane
  48959. */
  48960. yPlaneGizmo: PlaneDragGizmo;
  48961. /**
  48962. * Internal gizmo used for interactions on the xy plane
  48963. */
  48964. zPlaneGizmo: PlaneDragGizmo;
  48965. /**
  48966. * private variables
  48967. */
  48968. private _meshAttached;
  48969. private _updateGizmoRotationToMatchAttachedMesh;
  48970. private _snapDistance;
  48971. private _scaleRatio;
  48972. /** Fires an event when any of it's sub gizmos are dragged */
  48973. onDragStartObservable: Observable<unknown>;
  48974. /** Fires an event when any of it's sub gizmos are released from dragging */
  48975. onDragEndObservable: Observable<unknown>;
  48976. /**
  48977. * If set to true, planar drag is enabled
  48978. */
  48979. private _planarGizmoEnabled;
  48980. get attachedMesh(): Nullable<AbstractMesh>;
  48981. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48982. /**
  48983. * Creates a PositionGizmo
  48984. * @param gizmoLayer The utility layer the gizmo will be added to
  48985. */
  48986. constructor(gizmoLayer?: UtilityLayerRenderer);
  48987. /**
  48988. * If the planar drag gizmo is enabled
  48989. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48990. */
  48991. set planarGizmoEnabled(value: boolean);
  48992. get planarGizmoEnabled(): boolean;
  48993. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48994. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48995. /**
  48996. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48997. */
  48998. set snapDistance(value: number);
  48999. get snapDistance(): number;
  49000. /**
  49001. * Ratio for the scale of the gizmo (Default: 1)
  49002. */
  49003. set scaleRatio(value: number);
  49004. get scaleRatio(): number;
  49005. /**
  49006. * Disposes of the gizmo
  49007. */
  49008. dispose(): void;
  49009. /**
  49010. * CustomMeshes are not supported by this gizmo
  49011. * @param mesh The mesh to replace the default mesh of the gizmo
  49012. */
  49013. setCustomMesh(mesh: Mesh): void;
  49014. }
  49015. }
  49016. declare module BABYLON {
  49017. /**
  49018. * Single axis drag gizmo
  49019. */
  49020. export class AxisDragGizmo extends Gizmo {
  49021. /**
  49022. * Drag behavior responsible for the gizmos dragging interactions
  49023. */
  49024. dragBehavior: PointerDragBehavior;
  49025. private _pointerObserver;
  49026. /**
  49027. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49028. */
  49029. snapDistance: number;
  49030. /**
  49031. * Event that fires each time the gizmo snaps to a new location.
  49032. * * snapDistance is the the change in distance
  49033. */
  49034. onSnapObservable: Observable<{
  49035. snapDistance: number;
  49036. }>;
  49037. private _isEnabled;
  49038. private _parent;
  49039. private _arrow;
  49040. private _coloredMaterial;
  49041. private _hoverMaterial;
  49042. /** @hidden */
  49043. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49044. /** @hidden */
  49045. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49046. /**
  49047. * Creates an AxisDragGizmo
  49048. * @param gizmoLayer The utility layer the gizmo will be added to
  49049. * @param dragAxis The axis which the gizmo will be able to drag on
  49050. * @param color The color of the gizmo
  49051. */
  49052. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49053. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49054. /**
  49055. * If the gizmo is enabled
  49056. */
  49057. set isEnabled(value: boolean);
  49058. get isEnabled(): boolean;
  49059. /**
  49060. * Disposes of the gizmo
  49061. */
  49062. dispose(): void;
  49063. }
  49064. }
  49065. declare module BABYLON.Debug {
  49066. /**
  49067. * The Axes viewer will show 3 axes in a specific point in space
  49068. */
  49069. export class AxesViewer {
  49070. private _xAxis;
  49071. private _yAxis;
  49072. private _zAxis;
  49073. private _scaleLinesFactor;
  49074. private _instanced;
  49075. /**
  49076. * Gets the hosting scene
  49077. */
  49078. scene: Scene;
  49079. /**
  49080. * Gets or sets a number used to scale line length
  49081. */
  49082. scaleLines: number;
  49083. /** Gets the node hierarchy used to render x-axis */
  49084. get xAxis(): TransformNode;
  49085. /** Gets the node hierarchy used to render y-axis */
  49086. get yAxis(): TransformNode;
  49087. /** Gets the node hierarchy used to render z-axis */
  49088. get zAxis(): TransformNode;
  49089. /**
  49090. * Creates a new AxesViewer
  49091. * @param scene defines the hosting scene
  49092. * @param scaleLines defines a number used to scale line length (1 by default)
  49093. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49094. * @param xAxis defines the node hierarchy used to render the x-axis
  49095. * @param yAxis defines the node hierarchy used to render the y-axis
  49096. * @param zAxis defines the node hierarchy used to render the z-axis
  49097. */
  49098. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49099. /**
  49100. * Force the viewer to update
  49101. * @param position defines the position of the viewer
  49102. * @param xaxis defines the x axis of the viewer
  49103. * @param yaxis defines the y axis of the viewer
  49104. * @param zaxis defines the z axis of the viewer
  49105. */
  49106. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49107. /**
  49108. * Creates an instance of this axes viewer.
  49109. * @returns a new axes viewer with instanced meshes
  49110. */
  49111. createInstance(): AxesViewer;
  49112. /** Releases resources */
  49113. dispose(): void;
  49114. private static _SetRenderingGroupId;
  49115. }
  49116. }
  49117. declare module BABYLON.Debug {
  49118. /**
  49119. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49120. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49121. */
  49122. export class BoneAxesViewer extends AxesViewer {
  49123. /**
  49124. * Gets or sets the target mesh where to display the axes viewer
  49125. */
  49126. mesh: Nullable<Mesh>;
  49127. /**
  49128. * Gets or sets the target bone where to display the axes viewer
  49129. */
  49130. bone: Nullable<Bone>;
  49131. /** Gets current position */
  49132. pos: Vector3;
  49133. /** Gets direction of X axis */
  49134. xaxis: Vector3;
  49135. /** Gets direction of Y axis */
  49136. yaxis: Vector3;
  49137. /** Gets direction of Z axis */
  49138. zaxis: Vector3;
  49139. /**
  49140. * Creates a new BoneAxesViewer
  49141. * @param scene defines the hosting scene
  49142. * @param bone defines the target bone
  49143. * @param mesh defines the target mesh
  49144. * @param scaleLines defines a scaling factor for line length (1 by default)
  49145. */
  49146. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49147. /**
  49148. * Force the viewer to update
  49149. */
  49150. update(): void;
  49151. /** Releases resources */
  49152. dispose(): void;
  49153. }
  49154. }
  49155. declare module BABYLON {
  49156. /**
  49157. * Interface used to define scene explorer extensibility option
  49158. */
  49159. export interface IExplorerExtensibilityOption {
  49160. /**
  49161. * Define the option label
  49162. */
  49163. label: string;
  49164. /**
  49165. * Defines the action to execute on click
  49166. */
  49167. action: (entity: any) => void;
  49168. }
  49169. /**
  49170. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49171. */
  49172. export interface IExplorerExtensibilityGroup {
  49173. /**
  49174. * Defines a predicate to test if a given type mut be extended
  49175. */
  49176. predicate: (entity: any) => boolean;
  49177. /**
  49178. * Gets the list of options added to a type
  49179. */
  49180. entries: IExplorerExtensibilityOption[];
  49181. }
  49182. /**
  49183. * Interface used to define the options to use to create the Inspector
  49184. */
  49185. export interface IInspectorOptions {
  49186. /**
  49187. * Display in overlay mode (default: false)
  49188. */
  49189. overlay?: boolean;
  49190. /**
  49191. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49192. */
  49193. globalRoot?: HTMLElement;
  49194. /**
  49195. * Display the Scene explorer
  49196. */
  49197. showExplorer?: boolean;
  49198. /**
  49199. * Display the property inspector
  49200. */
  49201. showInspector?: boolean;
  49202. /**
  49203. * Display in embed mode (both panes on the right)
  49204. */
  49205. embedMode?: boolean;
  49206. /**
  49207. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49208. */
  49209. handleResize?: boolean;
  49210. /**
  49211. * Allow the panes to popup (default: true)
  49212. */
  49213. enablePopup?: boolean;
  49214. /**
  49215. * Allow the panes to be closed by users (default: true)
  49216. */
  49217. enableClose?: boolean;
  49218. /**
  49219. * Optional list of extensibility entries
  49220. */
  49221. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49222. /**
  49223. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49224. */
  49225. inspectorURL?: string;
  49226. /**
  49227. * Optional initial tab (default to DebugLayerTab.Properties)
  49228. */
  49229. initialTab?: DebugLayerTab;
  49230. }
  49231. interface Scene {
  49232. /**
  49233. * @hidden
  49234. * Backing field
  49235. */
  49236. _debugLayer: DebugLayer;
  49237. /**
  49238. * Gets the debug layer (aka Inspector) associated with the scene
  49239. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49240. */
  49241. debugLayer: DebugLayer;
  49242. }
  49243. /**
  49244. * Enum of inspector action tab
  49245. */
  49246. export enum DebugLayerTab {
  49247. /**
  49248. * Properties tag (default)
  49249. */
  49250. Properties = 0,
  49251. /**
  49252. * Debug tab
  49253. */
  49254. Debug = 1,
  49255. /**
  49256. * Statistics tab
  49257. */
  49258. Statistics = 2,
  49259. /**
  49260. * Tools tab
  49261. */
  49262. Tools = 3,
  49263. /**
  49264. * Settings tab
  49265. */
  49266. Settings = 4
  49267. }
  49268. /**
  49269. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49270. * what is happening in your scene
  49271. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49272. */
  49273. export class DebugLayer {
  49274. /**
  49275. * Define the url to get the inspector script from.
  49276. * By default it uses the babylonjs CDN.
  49277. * @ignoreNaming
  49278. */
  49279. static InspectorURL: string;
  49280. private _scene;
  49281. private BJSINSPECTOR;
  49282. private _onPropertyChangedObservable?;
  49283. /**
  49284. * Observable triggered when a property is changed through the inspector.
  49285. */
  49286. get onPropertyChangedObservable(): any;
  49287. /**
  49288. * Instantiates a new debug layer.
  49289. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49290. * what is happening in your scene
  49291. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49292. * @param scene Defines the scene to inspect
  49293. */
  49294. constructor(scene: Scene);
  49295. /** Creates the inspector window. */
  49296. private _createInspector;
  49297. /**
  49298. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49299. * @param entity defines the entity to select
  49300. * @param lineContainerTitle defines the specific block to highlight
  49301. */
  49302. select(entity: any, lineContainerTitle?: string): void;
  49303. /** Get the inspector from bundle or global */
  49304. private _getGlobalInspector;
  49305. /**
  49306. * Get if the inspector is visible or not.
  49307. * @returns true if visible otherwise, false
  49308. */
  49309. isVisible(): boolean;
  49310. /**
  49311. * Hide the inspector and close its window.
  49312. */
  49313. hide(): void;
  49314. /**
  49315. * Update the scene in the inspector
  49316. */
  49317. setAsActiveScene(): void;
  49318. /**
  49319. * Launch the debugLayer.
  49320. * @param config Define the configuration of the inspector
  49321. * @return a promise fulfilled when the debug layer is visible
  49322. */
  49323. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49324. }
  49325. }
  49326. declare module BABYLON {
  49327. /**
  49328. * Class containing static functions to help procedurally build meshes
  49329. */
  49330. export class BoxBuilder {
  49331. /**
  49332. * Creates a box mesh
  49333. * * The parameter `size` sets the size (float) of each box side (default 1)
  49334. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49335. * * 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)
  49336. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49338. * * 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
  49339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49340. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49341. * @param name defines the name of the mesh
  49342. * @param options defines the options used to create the mesh
  49343. * @param scene defines the hosting scene
  49344. * @returns the box mesh
  49345. */
  49346. static CreateBox(name: string, options: {
  49347. size?: number;
  49348. width?: number;
  49349. height?: number;
  49350. depth?: number;
  49351. faceUV?: Vector4[];
  49352. faceColors?: Color4[];
  49353. sideOrientation?: number;
  49354. frontUVs?: Vector4;
  49355. backUVs?: Vector4;
  49356. wrap?: boolean;
  49357. topBaseAt?: number;
  49358. bottomBaseAt?: number;
  49359. updatable?: boolean;
  49360. }, scene?: Nullable<Scene>): Mesh;
  49361. }
  49362. }
  49363. declare module BABYLON.Debug {
  49364. /**
  49365. * Used to show the physics impostor around the specific mesh
  49366. */
  49367. export class PhysicsViewer {
  49368. /** @hidden */
  49369. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49370. /** @hidden */
  49371. protected _meshes: Array<Nullable<AbstractMesh>>;
  49372. /** @hidden */
  49373. protected _scene: Nullable<Scene>;
  49374. /** @hidden */
  49375. protected _numMeshes: number;
  49376. /** @hidden */
  49377. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49378. private _renderFunction;
  49379. private _utilityLayer;
  49380. private _debugBoxMesh;
  49381. private _debugSphereMesh;
  49382. private _debugCylinderMesh;
  49383. private _debugMaterial;
  49384. private _debugMeshMeshes;
  49385. /**
  49386. * Creates a new PhysicsViewer
  49387. * @param scene defines the hosting scene
  49388. */
  49389. constructor(scene: Scene);
  49390. /** @hidden */
  49391. protected _updateDebugMeshes(): void;
  49392. /**
  49393. * Renders a specified physic impostor
  49394. * @param impostor defines the impostor to render
  49395. * @param targetMesh defines the mesh represented by the impostor
  49396. * @returns the new debug mesh used to render the impostor
  49397. */
  49398. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49399. /**
  49400. * Hides a specified physic impostor
  49401. * @param impostor defines the impostor to hide
  49402. */
  49403. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49404. private _getDebugMaterial;
  49405. private _getDebugBoxMesh;
  49406. private _getDebugSphereMesh;
  49407. private _getDebugCylinderMesh;
  49408. private _getDebugMeshMesh;
  49409. private _getDebugMesh;
  49410. /** Releases all resources */
  49411. dispose(): void;
  49412. }
  49413. }
  49414. declare module BABYLON {
  49415. /**
  49416. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49417. * in order to better appreciate the issue one might have.
  49418. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49419. */
  49420. export class RayHelper {
  49421. /**
  49422. * Defines the ray we are currently tryin to visualize.
  49423. */
  49424. ray: Nullable<Ray>;
  49425. private _renderPoints;
  49426. private _renderLine;
  49427. private _renderFunction;
  49428. private _scene;
  49429. private _updateToMeshFunction;
  49430. private _attachedToMesh;
  49431. private _meshSpaceDirection;
  49432. private _meshSpaceOrigin;
  49433. /**
  49434. * Helper function to create a colored helper in a scene in one line.
  49435. * @param ray Defines the ray we are currently tryin to visualize
  49436. * @param scene Defines the scene the ray is used in
  49437. * @param color Defines the color we want to see the ray in
  49438. * @returns The newly created ray helper.
  49439. */
  49440. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49441. /**
  49442. * Instantiate a new ray helper.
  49443. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49444. * in order to better appreciate the issue one might have.
  49445. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49446. * @param ray Defines the ray we are currently tryin to visualize
  49447. */
  49448. constructor(ray: Ray);
  49449. /**
  49450. * Shows the ray we are willing to debug.
  49451. * @param scene Defines the scene the ray needs to be rendered in
  49452. * @param color Defines the color the ray needs to be rendered in
  49453. */
  49454. show(scene: Scene, color?: Color3): void;
  49455. /**
  49456. * Hides the ray we are debugging.
  49457. */
  49458. hide(): void;
  49459. private _render;
  49460. /**
  49461. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49462. * @param mesh Defines the mesh we want the helper attached to
  49463. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49464. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49465. * @param length Defines the length of the ray
  49466. */
  49467. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49468. /**
  49469. * Detach the ray helper from the mesh it has previously been attached to.
  49470. */
  49471. detachFromMesh(): void;
  49472. private _updateToMesh;
  49473. /**
  49474. * Dispose the helper and release its associated resources.
  49475. */
  49476. dispose(): void;
  49477. }
  49478. }
  49479. declare module BABYLON.Debug {
  49480. /**
  49481. * Class used to render a debug view of a given skeleton
  49482. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49483. */
  49484. export class SkeletonViewer {
  49485. /** defines the skeleton to render */
  49486. skeleton: Skeleton;
  49487. /** defines the mesh attached to the skeleton */
  49488. mesh: AbstractMesh;
  49489. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49490. autoUpdateBonesMatrices: boolean;
  49491. /** defines the rendering group id to use with the viewer */
  49492. renderingGroupId: number;
  49493. /** Gets or sets the color used to render the skeleton */
  49494. color: Color3;
  49495. private _scene;
  49496. private _debugLines;
  49497. private _debugMesh;
  49498. private _isEnabled;
  49499. private _renderFunction;
  49500. private _utilityLayer;
  49501. /**
  49502. * Returns the mesh used to render the bones
  49503. */
  49504. get debugMesh(): Nullable<LinesMesh>;
  49505. /**
  49506. * Creates a new SkeletonViewer
  49507. * @param skeleton defines the skeleton to render
  49508. * @param mesh defines the mesh attached to the skeleton
  49509. * @param scene defines the hosting scene
  49510. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49511. * @param renderingGroupId defines the rendering group id to use with the viewer
  49512. */
  49513. constructor(
  49514. /** defines the skeleton to render */
  49515. skeleton: Skeleton,
  49516. /** defines the mesh attached to the skeleton */
  49517. mesh: AbstractMesh, scene: Scene,
  49518. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49519. autoUpdateBonesMatrices?: boolean,
  49520. /** defines the rendering group id to use with the viewer */
  49521. renderingGroupId?: number);
  49522. /** Gets or sets a boolean indicating if the viewer is enabled */
  49523. set isEnabled(value: boolean);
  49524. get isEnabled(): boolean;
  49525. private _getBonePosition;
  49526. private _getLinesForBonesWithLength;
  49527. private _getLinesForBonesNoLength;
  49528. /** Update the viewer to sync with current skeleton state */
  49529. update(): void;
  49530. /** Release associated resources */
  49531. dispose(): void;
  49532. }
  49533. }
  49534. declare module BABYLON {
  49535. /**
  49536. * Enum for Device Types
  49537. */
  49538. export enum DeviceType {
  49539. /** Generic */
  49540. Generic = 0,
  49541. /** Keyboard */
  49542. Keyboard = 1,
  49543. /** Mouse */
  49544. Mouse = 2,
  49545. /** Touch Pointers */
  49546. Touch = 3,
  49547. /** PS4 Dual Shock */
  49548. DualShock = 4,
  49549. /** Xbox */
  49550. Xbox = 5,
  49551. /** Switch Controller */
  49552. Switch = 6
  49553. }
  49554. /**
  49555. * Enum for All Pointers (Touch/Mouse)
  49556. */
  49557. export enum PointerInput {
  49558. /** Horizontal Axis */
  49559. Horizontal = 0,
  49560. /** Vertical Axis */
  49561. Vertical = 1,
  49562. /** Left Click or Touch */
  49563. LeftClick = 2,
  49564. /** Middle Click */
  49565. MiddleClick = 3,
  49566. /** Right Click */
  49567. RightClick = 4,
  49568. /** Browser Back */
  49569. BrowserBack = 5,
  49570. /** Browser Forward */
  49571. BrowserForward = 6
  49572. }
  49573. /**
  49574. * Enum for Dual Shock Gamepad
  49575. */
  49576. export enum DualShockInput {
  49577. /** Cross */
  49578. Cross = 0,
  49579. /** Circle */
  49580. Circle = 1,
  49581. /** Square */
  49582. Square = 2,
  49583. /** Triangle */
  49584. Triangle = 3,
  49585. /** L1 */
  49586. L1 = 4,
  49587. /** R1 */
  49588. R1 = 5,
  49589. /** L2 */
  49590. L2 = 6,
  49591. /** R2 */
  49592. R2 = 7,
  49593. /** Share */
  49594. Share = 8,
  49595. /** Options */
  49596. Options = 9,
  49597. /** L3 */
  49598. L3 = 10,
  49599. /** R3 */
  49600. R3 = 11,
  49601. /** DPadUp */
  49602. DPadUp = 12,
  49603. /** DPadDown */
  49604. DPadDown = 13,
  49605. /** DPadLeft */
  49606. DPadLeft = 14,
  49607. /** DRight */
  49608. DPadRight = 15,
  49609. /** Home */
  49610. Home = 16,
  49611. /** TouchPad */
  49612. TouchPad = 17,
  49613. /** LStickXAxis */
  49614. LStickXAxis = 18,
  49615. /** LStickYAxis */
  49616. LStickYAxis = 19,
  49617. /** RStickXAxis */
  49618. RStickXAxis = 20,
  49619. /** RStickYAxis */
  49620. RStickYAxis = 21
  49621. }
  49622. /**
  49623. * Enum for Xbox Gamepad
  49624. */
  49625. export enum XboxInput {
  49626. /** A */
  49627. A = 0,
  49628. /** B */
  49629. B = 1,
  49630. /** X */
  49631. X = 2,
  49632. /** Y */
  49633. Y = 3,
  49634. /** LB */
  49635. LB = 4,
  49636. /** RB */
  49637. RB = 5,
  49638. /** LT */
  49639. LT = 6,
  49640. /** RT */
  49641. RT = 7,
  49642. /** Back */
  49643. Back = 8,
  49644. /** Start */
  49645. Start = 9,
  49646. /** LS */
  49647. LS = 10,
  49648. /** RS */
  49649. RS = 11,
  49650. /** DPadUp */
  49651. DPadUp = 12,
  49652. /** DPadDown */
  49653. DPadDown = 13,
  49654. /** DPadLeft */
  49655. DPadLeft = 14,
  49656. /** DRight */
  49657. DPadRight = 15,
  49658. /** Home */
  49659. Home = 16,
  49660. /** LStickXAxis */
  49661. LStickXAxis = 17,
  49662. /** LStickYAxis */
  49663. LStickYAxis = 18,
  49664. /** RStickXAxis */
  49665. RStickXAxis = 19,
  49666. /** RStickYAxis */
  49667. RStickYAxis = 20
  49668. }
  49669. /**
  49670. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  49671. */
  49672. export enum SwitchInput {
  49673. /** B */
  49674. B = 0,
  49675. /** A */
  49676. A = 1,
  49677. /** Y */
  49678. Y = 2,
  49679. /** X */
  49680. X = 3,
  49681. /** L */
  49682. L = 4,
  49683. /** R */
  49684. R = 5,
  49685. /** ZL */
  49686. ZL = 6,
  49687. /** ZR */
  49688. ZR = 7,
  49689. /** Minus */
  49690. Minus = 8,
  49691. /** Plus */
  49692. Plus = 9,
  49693. /** LS */
  49694. LS = 10,
  49695. /** RS */
  49696. RS = 11,
  49697. /** DPadUp */
  49698. DPadUp = 12,
  49699. /** DPadDown */
  49700. DPadDown = 13,
  49701. /** DPadLeft */
  49702. DPadLeft = 14,
  49703. /** DRight */
  49704. DPadRight = 15,
  49705. /** Home */
  49706. Home = 16,
  49707. /** Capture */
  49708. Capture = 17,
  49709. /** LStickXAxis */
  49710. LStickXAxis = 18,
  49711. /** LStickYAxis */
  49712. LStickYAxis = 19,
  49713. /** RStickXAxis */
  49714. RStickXAxis = 20,
  49715. /** RStickYAxis */
  49716. RStickYAxis = 21
  49717. }
  49718. }
  49719. declare module BABYLON {
  49720. /**
  49721. * This class will take all inputs from Keyboard, Pointer, and
  49722. * any Gamepads and provide a polling system that all devices
  49723. * will use. This class assumes that there will only be one
  49724. * pointer device and one keyboard.
  49725. */
  49726. export class DeviceInputSystem implements IDisposable {
  49727. /**
  49728. * Callback to be triggered when a device is connected
  49729. */
  49730. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49731. /**
  49732. * Callback to be triggered when a device is disconnected
  49733. */
  49734. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49735. /**
  49736. * Callback to be triggered when event driven input is updated
  49737. */
  49738. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  49739. private _inputs;
  49740. private _gamepads;
  49741. private _keyboardActive;
  49742. private _pointerActive;
  49743. private _elementToAttachTo;
  49744. private _keyboardDownEvent;
  49745. private _keyboardUpEvent;
  49746. private _pointerMoveEvent;
  49747. private _pointerDownEvent;
  49748. private _pointerUpEvent;
  49749. private _gamepadConnectedEvent;
  49750. private _gamepadDisconnectedEvent;
  49751. private static _MAX_KEYCODES;
  49752. private static _MAX_POINTER_INPUTS;
  49753. /**
  49754. * Default Constructor
  49755. * @param engine - engine to pull input element from
  49756. */
  49757. constructor(engine: Engine);
  49758. /**
  49759. * Checks for current device input value, given an id and input index
  49760. * @param deviceName Id of connected device
  49761. * @param inputIndex Index of device input
  49762. * @returns Current value of input
  49763. */
  49764. /**
  49765. * Checks for current device input value, given an id and input index
  49766. * @param deviceType Enum specifiying device type
  49767. * @param deviceSlot "Slot" or index that device is referenced in
  49768. * @param inputIndex Id of input to be checked
  49769. * @returns Current value of input
  49770. */
  49771. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  49772. /**
  49773. * Dispose of all the eventlisteners
  49774. */
  49775. dispose(): void;
  49776. /**
  49777. * Add device and inputs to device array
  49778. * @param deviceType Enum specifiying device type
  49779. * @param deviceSlot "Slot" or index that device is referenced in
  49780. * @param numberOfInputs Number of input entries to create for given device
  49781. */
  49782. private _registerDevice;
  49783. /**
  49784. * Given a specific device name, remove that device from the device map
  49785. * @param deviceType Enum specifiying device type
  49786. * @param deviceSlot "Slot" or index that device is referenced in
  49787. */
  49788. private _unregisterDevice;
  49789. /**
  49790. * Handle all actions that come from keyboard interaction
  49791. */
  49792. private _handleKeyActions;
  49793. /**
  49794. * Handle all actions that come from pointer interaction
  49795. */
  49796. private _handlePointerActions;
  49797. /**
  49798. * Handle all actions that come from gamepad interaction
  49799. */
  49800. private _handleGamepadActions;
  49801. /**
  49802. * Update all non-event based devices with each frame
  49803. * @param deviceType Enum specifiying device type
  49804. * @param deviceSlot "Slot" or index that device is referenced in
  49805. * @param inputIndex Id of input to be checked
  49806. */
  49807. private _updateDevice;
  49808. /**
  49809. * Gets DeviceType from the device name
  49810. * @param deviceName Name of Device from DeviceInputSystem
  49811. * @returns DeviceType enum value
  49812. */
  49813. private _getGamepadDeviceType;
  49814. }
  49815. }
  49816. declare module BABYLON {
  49817. /**
  49818. * Type to handle enforcement of inputs
  49819. */
  49820. 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;
  49821. }
  49822. declare module BABYLON {
  49823. /**
  49824. * Class that handles all input for a specific device
  49825. */
  49826. export class DeviceSource<T extends DeviceType> {
  49827. /** Type of device */
  49828. readonly deviceType: DeviceType;
  49829. /** "Slot" or index that device is referenced in */
  49830. readonly deviceSlot: number;
  49831. /**
  49832. * Observable to handle device input changes per device
  49833. */
  49834. readonly onInputChangedObservable: Observable<{
  49835. inputIndex: DeviceInput<T>;
  49836. previousState: Nullable<number>;
  49837. currentState: Nullable<number>;
  49838. }>;
  49839. private readonly _deviceInputSystem;
  49840. /**
  49841. * Default Constructor
  49842. * @param deviceInputSystem Reference to DeviceInputSystem
  49843. * @param deviceType Type of device
  49844. * @param deviceSlot "Slot" or index that device is referenced in
  49845. */
  49846. constructor(deviceInputSystem: DeviceInputSystem,
  49847. /** Type of device */
  49848. deviceType: DeviceType,
  49849. /** "Slot" or index that device is referenced in */
  49850. deviceSlot?: number);
  49851. /**
  49852. * Get input for specific input
  49853. * @param inputIndex index of specific input on device
  49854. * @returns Input value from DeviceInputSystem
  49855. */
  49856. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  49857. }
  49858. /**
  49859. * Class to keep track of devices
  49860. */
  49861. export class DeviceSourceManager implements IDisposable {
  49862. /**
  49863. * Observable to be triggered when before a device is connected
  49864. */
  49865. readonly onBeforeDeviceConnectedObservable: Observable<{
  49866. deviceType: DeviceType;
  49867. deviceSlot: number;
  49868. }>;
  49869. /**
  49870. * Observable to be triggered when before a device is disconnected
  49871. */
  49872. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  49873. deviceType: DeviceType;
  49874. deviceSlot: number;
  49875. }>;
  49876. /**
  49877. * Observable to be triggered when after a device is connected
  49878. */
  49879. readonly onAfterDeviceConnectedObservable: Observable<{
  49880. deviceType: DeviceType;
  49881. deviceSlot: number;
  49882. }>;
  49883. /**
  49884. * Observable to be triggered when after a device is disconnected
  49885. */
  49886. readonly onAfterDeviceDisconnectedObservable: Observable<{
  49887. deviceType: DeviceType;
  49888. deviceSlot: number;
  49889. }>;
  49890. private readonly _devices;
  49891. private readonly _firstDevice;
  49892. private readonly _deviceInputSystem;
  49893. /**
  49894. * Default Constructor
  49895. * @param engine engine to pull input element from
  49896. */
  49897. constructor(engine: Engine);
  49898. /**
  49899. * Gets a DeviceSource, given a type and slot
  49900. * @param deviceType Enum specifying device type
  49901. * @param deviceSlot "Slot" or index that device is referenced in
  49902. * @returns DeviceSource object
  49903. */
  49904. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  49905. /**
  49906. * Gets an array of DeviceSource objects for a given device type
  49907. * @param deviceType Enum specifying device type
  49908. * @returns Array of DeviceSource objects
  49909. */
  49910. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  49911. /**
  49912. * Dispose of DeviceInputSystem and other parts
  49913. */
  49914. dispose(): void;
  49915. /**
  49916. * Function to add device name to device list
  49917. * @param deviceType Enum specifying device type
  49918. * @param deviceSlot "Slot" or index that device is referenced in
  49919. */
  49920. private _addDevice;
  49921. /**
  49922. * Function to remove device name to device list
  49923. * @param deviceType Enum specifying device type
  49924. * @param deviceSlot "Slot" or index that device is referenced in
  49925. */
  49926. private _removeDevice;
  49927. /**
  49928. * Updates array storing first connected device of each type
  49929. * @param type Type of Device
  49930. */
  49931. private _updateFirstDevices;
  49932. }
  49933. }
  49934. declare module BABYLON {
  49935. /**
  49936. * Options to create the null engine
  49937. */
  49938. export class NullEngineOptions {
  49939. /**
  49940. * Render width (Default: 512)
  49941. */
  49942. renderWidth: number;
  49943. /**
  49944. * Render height (Default: 256)
  49945. */
  49946. renderHeight: number;
  49947. /**
  49948. * Texture size (Default: 512)
  49949. */
  49950. textureSize: number;
  49951. /**
  49952. * If delta time between frames should be constant
  49953. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49954. */
  49955. deterministicLockstep: boolean;
  49956. /**
  49957. * Maximum about of steps between frames (Default: 4)
  49958. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49959. */
  49960. lockstepMaxSteps: number;
  49961. }
  49962. /**
  49963. * The null engine class provides support for headless version of babylon.js.
  49964. * This can be used in server side scenario or for testing purposes
  49965. */
  49966. export class NullEngine extends Engine {
  49967. private _options;
  49968. /**
  49969. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  49970. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49971. * @returns true if engine is in deterministic lock step mode
  49972. */
  49973. isDeterministicLockStep(): boolean;
  49974. /**
  49975. * Gets the max steps when engine is running in deterministic lock step
  49976. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49977. * @returns the max steps
  49978. */
  49979. getLockstepMaxSteps(): number;
  49980. /**
  49981. * Gets the current hardware scaling level.
  49982. * By default the hardware scaling level is computed from the window device ratio.
  49983. * 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.
  49984. * @returns a number indicating the current hardware scaling level
  49985. */
  49986. getHardwareScalingLevel(): number;
  49987. constructor(options?: NullEngineOptions);
  49988. /**
  49989. * Creates a vertex buffer
  49990. * @param vertices the data for the vertex buffer
  49991. * @returns the new WebGL static buffer
  49992. */
  49993. createVertexBuffer(vertices: FloatArray): DataBuffer;
  49994. /**
  49995. * Creates a new index buffer
  49996. * @param indices defines the content of the index buffer
  49997. * @param updatable defines if the index buffer must be updatable
  49998. * @returns a new webGL buffer
  49999. */
  50000. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50001. /**
  50002. * Clear the current render buffer or the current render target (if any is set up)
  50003. * @param color defines the color to use
  50004. * @param backBuffer defines if the back buffer must be cleared
  50005. * @param depth defines if the depth buffer must be cleared
  50006. * @param stencil defines if the stencil buffer must be cleared
  50007. */
  50008. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50009. /**
  50010. * Gets the current render width
  50011. * @param useScreen defines if screen size must be used (or the current render target if any)
  50012. * @returns a number defining the current render width
  50013. */
  50014. getRenderWidth(useScreen?: boolean): number;
  50015. /**
  50016. * Gets the current render height
  50017. * @param useScreen defines if screen size must be used (or the current render target if any)
  50018. * @returns a number defining the current render height
  50019. */
  50020. getRenderHeight(useScreen?: boolean): number;
  50021. /**
  50022. * Set the WebGL's viewport
  50023. * @param viewport defines the viewport element to be used
  50024. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50025. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50026. */
  50027. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50028. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50029. /**
  50030. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50031. * @param pipelineContext defines the pipeline context to use
  50032. * @param uniformsNames defines the list of uniform names
  50033. * @returns an array of webGL uniform locations
  50034. */
  50035. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50036. /**
  50037. * Gets the lsit of active attributes for a given webGL program
  50038. * @param pipelineContext defines the pipeline context to use
  50039. * @param attributesNames defines the list of attribute names to get
  50040. * @returns an array of indices indicating the offset of each attribute
  50041. */
  50042. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50043. /**
  50044. * Binds an effect to the webGL context
  50045. * @param effect defines the effect to bind
  50046. */
  50047. bindSamplers(effect: Effect): void;
  50048. /**
  50049. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50050. * @param effect defines the effect to activate
  50051. */
  50052. enableEffect(effect: Effect): void;
  50053. /**
  50054. * Set various states to the webGL context
  50055. * @param culling defines backface culling state
  50056. * @param zOffset defines the value to apply to zOffset (0 by default)
  50057. * @param force defines if states must be applied even if cache is up to date
  50058. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50059. */
  50060. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50061. /**
  50062. * Set the value of an uniform to an array of int32
  50063. * @param uniform defines the webGL uniform location where to store the value
  50064. * @param array defines the array of int32 to store
  50065. */
  50066. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50067. /**
  50068. * Set the value of an uniform to an array of int32 (stored as vec2)
  50069. * @param uniform defines the webGL uniform location where to store the value
  50070. * @param array defines the array of int32 to store
  50071. */
  50072. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50073. /**
  50074. * Set the value of an uniform to an array of int32 (stored as vec3)
  50075. * @param uniform defines the webGL uniform location where to store the value
  50076. * @param array defines the array of int32 to store
  50077. */
  50078. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50079. /**
  50080. * Set the value of an uniform to an array of int32 (stored as vec4)
  50081. * @param uniform defines the webGL uniform location where to store the value
  50082. * @param array defines the array of int32 to store
  50083. */
  50084. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50085. /**
  50086. * Set the value of an uniform to an array of float32
  50087. * @param uniform defines the webGL uniform location where to store the value
  50088. * @param array defines the array of float32 to store
  50089. */
  50090. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50091. /**
  50092. * Set the value of an uniform to an array of float32 (stored as vec2)
  50093. * @param uniform defines the webGL uniform location where to store the value
  50094. * @param array defines the array of float32 to store
  50095. */
  50096. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50097. /**
  50098. * Set the value of an uniform to an array of float32 (stored as vec3)
  50099. * @param uniform defines the webGL uniform location where to store the value
  50100. * @param array defines the array of float32 to store
  50101. */
  50102. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50103. /**
  50104. * Set the value of an uniform to an array of float32 (stored as vec4)
  50105. * @param uniform defines the webGL uniform location where to store the value
  50106. * @param array defines the array of float32 to store
  50107. */
  50108. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50109. /**
  50110. * Set the value of an uniform to an array of number
  50111. * @param uniform defines the webGL uniform location where to store the value
  50112. * @param array defines the array of number to store
  50113. */
  50114. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50115. /**
  50116. * Set the value of an uniform to an array of number (stored as vec2)
  50117. * @param uniform defines the webGL uniform location where to store the value
  50118. * @param array defines the array of number to store
  50119. */
  50120. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50121. /**
  50122. * Set the value of an uniform to an array of number (stored as vec3)
  50123. * @param uniform defines the webGL uniform location where to store the value
  50124. * @param array defines the array of number to store
  50125. */
  50126. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50127. /**
  50128. * Set the value of an uniform to an array of number (stored as vec4)
  50129. * @param uniform defines the webGL uniform location where to store the value
  50130. * @param array defines the array of number to store
  50131. */
  50132. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50133. /**
  50134. * Set the value of an uniform to an array of float32 (stored as matrices)
  50135. * @param uniform defines the webGL uniform location where to store the value
  50136. * @param matrices defines the array of float32 to store
  50137. */
  50138. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50139. /**
  50140. * Set the value of an uniform to a matrix (3x3)
  50141. * @param uniform defines the webGL uniform location where to store the value
  50142. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50143. */
  50144. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50145. /**
  50146. * Set the value of an uniform to a matrix (2x2)
  50147. * @param uniform defines the webGL uniform location where to store the value
  50148. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50149. */
  50150. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50151. /**
  50152. * Set the value of an uniform to a number (float)
  50153. * @param uniform defines the webGL uniform location where to store the value
  50154. * @param value defines the float number to store
  50155. */
  50156. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50157. /**
  50158. * Set the value of an uniform to a vec2
  50159. * @param uniform defines the webGL uniform location where to store the value
  50160. * @param x defines the 1st component of the value
  50161. * @param y defines the 2nd component of the value
  50162. */
  50163. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50164. /**
  50165. * Set the value of an uniform to a vec3
  50166. * @param uniform defines the webGL uniform location where to store the value
  50167. * @param x defines the 1st component of the value
  50168. * @param y defines the 2nd component of the value
  50169. * @param z defines the 3rd component of the value
  50170. */
  50171. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50172. /**
  50173. * Set the value of an uniform to a boolean
  50174. * @param uniform defines the webGL uniform location where to store the value
  50175. * @param bool defines the boolean to store
  50176. */
  50177. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50178. /**
  50179. * Set the value of an uniform to a vec4
  50180. * @param uniform defines the webGL uniform location where to store the value
  50181. * @param x defines the 1st component of the value
  50182. * @param y defines the 2nd component of the value
  50183. * @param z defines the 3rd component of the value
  50184. * @param w defines the 4th component of the value
  50185. */
  50186. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50187. /**
  50188. * Sets the current alpha mode
  50189. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50190. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50191. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50192. */
  50193. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50194. /**
  50195. * Bind webGl buffers directly to the webGL context
  50196. * @param vertexBuffers defines the vertex buffer to bind
  50197. * @param indexBuffer defines the index buffer to bind
  50198. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50199. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50200. * @param effect defines the effect associated with the vertex buffer
  50201. */
  50202. bindBuffers(vertexBuffers: {
  50203. [key: string]: VertexBuffer;
  50204. }, indexBuffer: DataBuffer, effect: Effect): void;
  50205. /**
  50206. * Force the entire cache to be cleared
  50207. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50208. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50209. */
  50210. wipeCaches(bruteForce?: boolean): void;
  50211. /**
  50212. * Send a draw order
  50213. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50214. * @param indexStart defines the starting index
  50215. * @param indexCount defines the number of index to draw
  50216. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50217. */
  50218. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50219. /**
  50220. * Draw a list of indexed primitives
  50221. * @param fillMode defines the primitive to use
  50222. * @param indexStart defines the starting index
  50223. * @param indexCount defines the number of index to draw
  50224. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50225. */
  50226. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50227. /**
  50228. * Draw a list of unindexed primitives
  50229. * @param fillMode defines the primitive to use
  50230. * @param verticesStart defines the index of first vertex to draw
  50231. * @param verticesCount defines the count of vertices to draw
  50232. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50233. */
  50234. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50235. /** @hidden */
  50236. _createTexture(): WebGLTexture;
  50237. /** @hidden */
  50238. _releaseTexture(texture: InternalTexture): void;
  50239. /**
  50240. * Usually called from Texture.ts.
  50241. * Passed information to create a WebGLTexture
  50242. * @param urlArg defines a value which contains one of the following:
  50243. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50244. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50245. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50246. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50247. * @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)
  50248. * @param scene needed for loading to the correct scene
  50249. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50250. * @param onLoad optional callback to be called upon successful completion
  50251. * @param onError optional callback to be called upon failure
  50252. * @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
  50253. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50254. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50255. * @param forcedExtension defines the extension to use to pick the right loader
  50256. * @param mimeType defines an optional mime type
  50257. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50258. */
  50259. 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;
  50260. /**
  50261. * Creates a new render target texture
  50262. * @param size defines the size of the texture
  50263. * @param options defines the options used to create the texture
  50264. * @returns a new render target texture stored in an InternalTexture
  50265. */
  50266. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50267. /**
  50268. * Update the sampling mode of a given texture
  50269. * @param samplingMode defines the required sampling mode
  50270. * @param texture defines the texture to update
  50271. */
  50272. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50273. /**
  50274. * Binds the frame buffer to the specified texture.
  50275. * @param texture The texture to render to or null for the default canvas
  50276. * @param faceIndex The face of the texture to render to in case of cube texture
  50277. * @param requiredWidth The width of the target to render to
  50278. * @param requiredHeight The height of the target to render to
  50279. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50280. * @param lodLevel defines le lod level to bind to the frame buffer
  50281. */
  50282. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50283. /**
  50284. * Unbind the current render target texture from the webGL context
  50285. * @param texture defines the render target texture to unbind
  50286. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50287. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50288. */
  50289. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50290. /**
  50291. * Creates a dynamic vertex buffer
  50292. * @param vertices the data for the dynamic vertex buffer
  50293. * @returns the new WebGL dynamic buffer
  50294. */
  50295. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50296. /**
  50297. * Update the content of a dynamic texture
  50298. * @param texture defines the texture to update
  50299. * @param canvas defines the canvas containing the source
  50300. * @param invertY defines if data must be stored with Y axis inverted
  50301. * @param premulAlpha defines if alpha is stored as premultiplied
  50302. * @param format defines the format of the data
  50303. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50304. */
  50305. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50306. /**
  50307. * Gets a boolean indicating if all created effects are ready
  50308. * @returns true if all effects are ready
  50309. */
  50310. areAllEffectsReady(): boolean;
  50311. /**
  50312. * @hidden
  50313. * Get the current error code of the webGL context
  50314. * @returns the error code
  50315. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50316. */
  50317. getError(): number;
  50318. /** @hidden */
  50319. _getUnpackAlignement(): number;
  50320. /** @hidden */
  50321. _unpackFlipY(value: boolean): void;
  50322. /**
  50323. * Update a dynamic index buffer
  50324. * @param indexBuffer defines the target index buffer
  50325. * @param indices defines the data to update
  50326. * @param offset defines the offset in the target index buffer where update should start
  50327. */
  50328. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50329. /**
  50330. * Updates a dynamic vertex buffer.
  50331. * @param vertexBuffer the vertex buffer to update
  50332. * @param vertices the data used to update the vertex buffer
  50333. * @param byteOffset the byte offset of the data (optional)
  50334. * @param byteLength the byte length of the data (optional)
  50335. */
  50336. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50337. /** @hidden */
  50338. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50339. /** @hidden */
  50340. _bindTexture(channel: number, texture: InternalTexture): void;
  50341. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50342. /**
  50343. * 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
  50344. */
  50345. releaseEffects(): void;
  50346. displayLoadingUI(): void;
  50347. hideLoadingUI(): void;
  50348. /** @hidden */
  50349. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50350. /** @hidden */
  50351. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50352. /** @hidden */
  50353. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50354. /** @hidden */
  50355. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50356. }
  50357. }
  50358. declare module BABYLON {
  50359. /**
  50360. * @hidden
  50361. **/
  50362. export class _TimeToken {
  50363. _startTimeQuery: Nullable<WebGLQuery>;
  50364. _endTimeQuery: Nullable<WebGLQuery>;
  50365. _timeElapsedQuery: Nullable<WebGLQuery>;
  50366. _timeElapsedQueryEnded: boolean;
  50367. }
  50368. }
  50369. declare module BABYLON {
  50370. /** @hidden */
  50371. export class _OcclusionDataStorage {
  50372. /** @hidden */
  50373. occlusionInternalRetryCounter: number;
  50374. /** @hidden */
  50375. isOcclusionQueryInProgress: boolean;
  50376. /** @hidden */
  50377. isOccluded: boolean;
  50378. /** @hidden */
  50379. occlusionRetryCount: number;
  50380. /** @hidden */
  50381. occlusionType: number;
  50382. /** @hidden */
  50383. occlusionQueryAlgorithmType: number;
  50384. }
  50385. interface Engine {
  50386. /**
  50387. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50388. * @return the new query
  50389. */
  50390. createQuery(): WebGLQuery;
  50391. /**
  50392. * Delete and release a webGL query
  50393. * @param query defines the query to delete
  50394. * @return the current engine
  50395. */
  50396. deleteQuery(query: WebGLQuery): Engine;
  50397. /**
  50398. * Check if a given query has resolved and got its value
  50399. * @param query defines the query to check
  50400. * @returns true if the query got its value
  50401. */
  50402. isQueryResultAvailable(query: WebGLQuery): boolean;
  50403. /**
  50404. * Gets the value of a given query
  50405. * @param query defines the query to check
  50406. * @returns the value of the query
  50407. */
  50408. getQueryResult(query: WebGLQuery): number;
  50409. /**
  50410. * Initiates an occlusion query
  50411. * @param algorithmType defines the algorithm to use
  50412. * @param query defines the query to use
  50413. * @returns the current engine
  50414. * @see http://doc.babylonjs.com/features/occlusionquery
  50415. */
  50416. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50417. /**
  50418. * Ends an occlusion query
  50419. * @see http://doc.babylonjs.com/features/occlusionquery
  50420. * @param algorithmType defines the algorithm to use
  50421. * @returns the current engine
  50422. */
  50423. endOcclusionQuery(algorithmType: number): Engine;
  50424. /**
  50425. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50426. * Please note that only one query can be issued at a time
  50427. * @returns a time token used to track the time span
  50428. */
  50429. startTimeQuery(): Nullable<_TimeToken>;
  50430. /**
  50431. * Ends a time query
  50432. * @param token defines the token used to measure the time span
  50433. * @returns the time spent (in ns)
  50434. */
  50435. endTimeQuery(token: _TimeToken): int;
  50436. /** @hidden */
  50437. _currentNonTimestampToken: Nullable<_TimeToken>;
  50438. /** @hidden */
  50439. _createTimeQuery(): WebGLQuery;
  50440. /** @hidden */
  50441. _deleteTimeQuery(query: WebGLQuery): void;
  50442. /** @hidden */
  50443. _getGlAlgorithmType(algorithmType: number): number;
  50444. /** @hidden */
  50445. _getTimeQueryResult(query: WebGLQuery): any;
  50446. /** @hidden */
  50447. _getTimeQueryAvailability(query: WebGLQuery): any;
  50448. }
  50449. interface AbstractMesh {
  50450. /**
  50451. * Backing filed
  50452. * @hidden
  50453. */
  50454. __occlusionDataStorage: _OcclusionDataStorage;
  50455. /**
  50456. * Access property
  50457. * @hidden
  50458. */
  50459. _occlusionDataStorage: _OcclusionDataStorage;
  50460. /**
  50461. * 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.
  50462. * The default value is -1 which means don't break the query and wait till the result
  50463. * @see http://doc.babylonjs.com/features/occlusionquery
  50464. */
  50465. occlusionRetryCount: number;
  50466. /**
  50467. * 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:
  50468. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50469. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50470. * * 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.
  50471. * @see http://doc.babylonjs.com/features/occlusionquery
  50472. */
  50473. occlusionType: number;
  50474. /**
  50475. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50476. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50477. * * 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.
  50478. * @see http://doc.babylonjs.com/features/occlusionquery
  50479. */
  50480. occlusionQueryAlgorithmType: number;
  50481. /**
  50482. * 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
  50483. * @see http://doc.babylonjs.com/features/occlusionquery
  50484. */
  50485. isOccluded: boolean;
  50486. /**
  50487. * Flag to check the progress status of the query
  50488. * @see http://doc.babylonjs.com/features/occlusionquery
  50489. */
  50490. isOcclusionQueryInProgress: boolean;
  50491. }
  50492. }
  50493. declare module BABYLON {
  50494. /** @hidden */
  50495. export var _forceTransformFeedbackToBundle: boolean;
  50496. interface Engine {
  50497. /**
  50498. * Creates a webGL transform feedback object
  50499. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50500. * @returns the webGL transform feedback object
  50501. */
  50502. createTransformFeedback(): WebGLTransformFeedback;
  50503. /**
  50504. * Delete a webGL transform feedback object
  50505. * @param value defines the webGL transform feedback object to delete
  50506. */
  50507. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50508. /**
  50509. * Bind a webGL transform feedback object to the webgl context
  50510. * @param value defines the webGL transform feedback object to bind
  50511. */
  50512. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50513. /**
  50514. * Begins a transform feedback operation
  50515. * @param usePoints defines if points or triangles must be used
  50516. */
  50517. beginTransformFeedback(usePoints: boolean): void;
  50518. /**
  50519. * Ends a transform feedback operation
  50520. */
  50521. endTransformFeedback(): void;
  50522. /**
  50523. * Specify the varyings to use with transform feedback
  50524. * @param program defines the associated webGL program
  50525. * @param value defines the list of strings representing the varying names
  50526. */
  50527. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50528. /**
  50529. * Bind a webGL buffer for a transform feedback operation
  50530. * @param value defines the webGL buffer to bind
  50531. */
  50532. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50533. }
  50534. }
  50535. declare module BABYLON {
  50536. /**
  50537. * Creation options of the multi render target texture.
  50538. */
  50539. export interface IMultiRenderTargetOptions {
  50540. /**
  50541. * Define if the texture needs to create mip maps after render.
  50542. */
  50543. generateMipMaps?: boolean;
  50544. /**
  50545. * Define the types of all the draw buffers we want to create
  50546. */
  50547. types?: number[];
  50548. /**
  50549. * Define the sampling modes of all the draw buffers we want to create
  50550. */
  50551. samplingModes?: number[];
  50552. /**
  50553. * Define if a depth buffer is required
  50554. */
  50555. generateDepthBuffer?: boolean;
  50556. /**
  50557. * Define if a stencil buffer is required
  50558. */
  50559. generateStencilBuffer?: boolean;
  50560. /**
  50561. * Define if a depth texture is required instead of a depth buffer
  50562. */
  50563. generateDepthTexture?: boolean;
  50564. /**
  50565. * Define the number of desired draw buffers
  50566. */
  50567. textureCount?: number;
  50568. /**
  50569. * Define if aspect ratio should be adapted to the texture or stay the scene one
  50570. */
  50571. doNotChangeAspectRatio?: boolean;
  50572. /**
  50573. * Define the default type of the buffers we are creating
  50574. */
  50575. defaultType?: number;
  50576. }
  50577. /**
  50578. * A multi render target, like a render target provides the ability to render to a texture.
  50579. * Unlike the render target, it can render to several draw buffers in one draw.
  50580. * This is specially interesting in deferred rendering or for any effects requiring more than
  50581. * just one color from a single pass.
  50582. */
  50583. export class MultiRenderTarget extends RenderTargetTexture {
  50584. private _internalTextures;
  50585. private _textures;
  50586. private _multiRenderTargetOptions;
  50587. /**
  50588. * Get if draw buffers are currently supported by the used hardware and browser.
  50589. */
  50590. get isSupported(): boolean;
  50591. /**
  50592. * Get the list of textures generated by the multi render target.
  50593. */
  50594. get textures(): Texture[];
  50595. /**
  50596. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  50597. */
  50598. get depthTexture(): Texture;
  50599. /**
  50600. * Set the wrapping mode on U of all the textures we are rendering to.
  50601. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50602. */
  50603. set wrapU(wrap: number);
  50604. /**
  50605. * Set the wrapping mode on V of all the textures we are rendering to.
  50606. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50607. */
  50608. set wrapV(wrap: number);
  50609. /**
  50610. * Instantiate a new multi render target texture.
  50611. * A multi render target, like a render target provides the ability to render to a texture.
  50612. * Unlike the render target, it can render to several draw buffers in one draw.
  50613. * This is specially interesting in deferred rendering or for any effects requiring more than
  50614. * just one color from a single pass.
  50615. * @param name Define the name of the texture
  50616. * @param size Define the size of the buffers to render to
  50617. * @param count Define the number of target we are rendering into
  50618. * @param scene Define the scene the texture belongs to
  50619. * @param options Define the options used to create the multi render target
  50620. */
  50621. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  50622. /** @hidden */
  50623. _rebuild(): void;
  50624. private _createInternalTextures;
  50625. private _createTextures;
  50626. /**
  50627. * Define the number of samples used if MSAA is enabled.
  50628. */
  50629. get samples(): number;
  50630. set samples(value: number);
  50631. /**
  50632. * Resize all the textures in the multi render target.
  50633. * Be carrefull as it will recreate all the data in the new texture.
  50634. * @param size Define the new size
  50635. */
  50636. resize(size: any): void;
  50637. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  50638. /**
  50639. * Dispose the render targets and their associated resources
  50640. */
  50641. dispose(): void;
  50642. /**
  50643. * Release all the underlying texture used as draw buffers.
  50644. */
  50645. releaseInternalTextures(): void;
  50646. }
  50647. }
  50648. declare module BABYLON {
  50649. interface ThinEngine {
  50650. /**
  50651. * Unbind a list of render target textures from the webGL context
  50652. * This is used only when drawBuffer extension or webGL2 are active
  50653. * @param textures defines the render target textures to unbind
  50654. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50655. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50656. */
  50657. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  50658. /**
  50659. * Create a multi render target texture
  50660. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  50661. * @param size defines the size of the texture
  50662. * @param options defines the creation options
  50663. * @returns the cube texture as an InternalTexture
  50664. */
  50665. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  50666. /**
  50667. * Update the sample count for a given multiple render target texture
  50668. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  50669. * @param textures defines the textures to update
  50670. * @param samples defines the sample count to set
  50671. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  50672. */
  50673. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  50674. }
  50675. }
  50676. declare module BABYLON {
  50677. /**
  50678. * Class used to define an additional view for the engine
  50679. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50680. */
  50681. export class EngineView {
  50682. /** Defines the canvas where to render the view */
  50683. target: HTMLCanvasElement;
  50684. /** Defines an optional camera used to render the view (will use active camera else) */
  50685. camera?: Camera;
  50686. }
  50687. interface Engine {
  50688. /**
  50689. * Gets or sets the HTML element to use for attaching events
  50690. */
  50691. inputElement: Nullable<HTMLElement>;
  50692. /**
  50693. * Gets the current engine view
  50694. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50695. */
  50696. activeView: Nullable<EngineView>;
  50697. /** Gets or sets the list of views */
  50698. views: EngineView[];
  50699. /**
  50700. * Register a new child canvas
  50701. * @param canvas defines the canvas to register
  50702. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  50703. * @returns the associated view
  50704. */
  50705. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  50706. /**
  50707. * Remove a registered child canvas
  50708. * @param canvas defines the canvas to remove
  50709. * @returns the current engine
  50710. */
  50711. unRegisterView(canvas: HTMLCanvasElement): Engine;
  50712. }
  50713. }
  50714. declare module BABYLON {
  50715. interface Engine {
  50716. /** @hidden */
  50717. _excludedCompressedTextures: string[];
  50718. /** @hidden */
  50719. _textureFormatInUse: string;
  50720. /**
  50721. * Gets the list of texture formats supported
  50722. */
  50723. readonly texturesSupported: Array<string>;
  50724. /**
  50725. * Gets the texture format in use
  50726. */
  50727. readonly textureFormatInUse: Nullable<string>;
  50728. /**
  50729. * Set the compressed texture extensions or file names to skip.
  50730. *
  50731. * @param skippedFiles defines the list of those texture files you want to skip
  50732. * Example: [".dds", ".env", "myfile.png"]
  50733. */
  50734. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  50735. /**
  50736. * Set the compressed texture format to use, based on the formats you have, and the formats
  50737. * supported by the hardware / browser.
  50738. *
  50739. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  50740. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  50741. * to API arguments needed to compressed textures. This puts the burden on the container
  50742. * generator to house the arcane code for determining these for current & future formats.
  50743. *
  50744. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50745. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50746. *
  50747. * Note: The result of this call is not taken into account when a texture is base64.
  50748. *
  50749. * @param formatsAvailable defines the list of those format families you have created
  50750. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  50751. *
  50752. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  50753. * @returns The extension selected.
  50754. */
  50755. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  50756. }
  50757. }
  50758. declare module BABYLON {
  50759. /**
  50760. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50761. */
  50762. export interface CubeMapInfo {
  50763. /**
  50764. * The pixel array for the front face.
  50765. * This is stored in format, left to right, up to down format.
  50766. */
  50767. front: Nullable<ArrayBufferView>;
  50768. /**
  50769. * The pixel array for the back face.
  50770. * This is stored in format, left to right, up to down format.
  50771. */
  50772. back: Nullable<ArrayBufferView>;
  50773. /**
  50774. * The pixel array for the left face.
  50775. * This is stored in format, left to right, up to down format.
  50776. */
  50777. left: Nullable<ArrayBufferView>;
  50778. /**
  50779. * The pixel array for the right face.
  50780. * This is stored in format, left to right, up to down format.
  50781. */
  50782. right: Nullable<ArrayBufferView>;
  50783. /**
  50784. * The pixel array for the up face.
  50785. * This is stored in format, left to right, up to down format.
  50786. */
  50787. up: Nullable<ArrayBufferView>;
  50788. /**
  50789. * The pixel array for the down face.
  50790. * This is stored in format, left to right, up to down format.
  50791. */
  50792. down: Nullable<ArrayBufferView>;
  50793. /**
  50794. * The size of the cubemap stored.
  50795. *
  50796. * Each faces will be size * size pixels.
  50797. */
  50798. size: number;
  50799. /**
  50800. * The format of the texture.
  50801. *
  50802. * RGBA, RGB.
  50803. */
  50804. format: number;
  50805. /**
  50806. * The type of the texture data.
  50807. *
  50808. * UNSIGNED_INT, FLOAT.
  50809. */
  50810. type: number;
  50811. /**
  50812. * Specifies whether the texture is in gamma space.
  50813. */
  50814. gammaSpace: boolean;
  50815. }
  50816. /**
  50817. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50818. */
  50819. export class PanoramaToCubeMapTools {
  50820. private static FACE_LEFT;
  50821. private static FACE_RIGHT;
  50822. private static FACE_FRONT;
  50823. private static FACE_BACK;
  50824. private static FACE_DOWN;
  50825. private static FACE_UP;
  50826. /**
  50827. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50828. *
  50829. * @param float32Array The source data.
  50830. * @param inputWidth The width of the input panorama.
  50831. * @param inputHeight The height of the input panorama.
  50832. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50833. * @return The cubemap data
  50834. */
  50835. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50836. private static CreateCubemapTexture;
  50837. private static CalcProjectionSpherical;
  50838. }
  50839. }
  50840. declare module BABYLON {
  50841. /**
  50842. * Helper class dealing with the extraction of spherical polynomial dataArray
  50843. * from a cube map.
  50844. */
  50845. export class CubeMapToSphericalPolynomialTools {
  50846. private static FileFaces;
  50847. /**
  50848. * Converts a texture to the according Spherical Polynomial data.
  50849. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50850. *
  50851. * @param texture The texture to extract the information from.
  50852. * @return The Spherical Polynomial data.
  50853. */
  50854. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  50855. /**
  50856. * Converts a cubemap to the according Spherical Polynomial data.
  50857. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50858. *
  50859. * @param cubeInfo The Cube map to extract the information from.
  50860. * @return The Spherical Polynomial data.
  50861. */
  50862. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  50863. }
  50864. }
  50865. declare module BABYLON {
  50866. interface BaseTexture {
  50867. /**
  50868. * Get the polynomial representation of the texture data.
  50869. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  50870. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  50871. */
  50872. sphericalPolynomial: Nullable<SphericalPolynomial>;
  50873. }
  50874. }
  50875. declare module BABYLON {
  50876. /** @hidden */
  50877. export var rgbdEncodePixelShader: {
  50878. name: string;
  50879. shader: string;
  50880. };
  50881. }
  50882. declare module BABYLON {
  50883. /** @hidden */
  50884. export var rgbdDecodePixelShader: {
  50885. name: string;
  50886. shader: string;
  50887. };
  50888. }
  50889. declare module BABYLON {
  50890. /**
  50891. * Raw texture data and descriptor sufficient for WebGL texture upload
  50892. */
  50893. export interface EnvironmentTextureInfo {
  50894. /**
  50895. * Version of the environment map
  50896. */
  50897. version: number;
  50898. /**
  50899. * Width of image
  50900. */
  50901. width: number;
  50902. /**
  50903. * Irradiance information stored in the file.
  50904. */
  50905. irradiance: any;
  50906. /**
  50907. * Specular information stored in the file.
  50908. */
  50909. specular: any;
  50910. }
  50911. /**
  50912. * Defines One Image in the file. It requires only the position in the file
  50913. * as well as the length.
  50914. */
  50915. interface BufferImageData {
  50916. /**
  50917. * Length of the image data.
  50918. */
  50919. length: number;
  50920. /**
  50921. * Position of the data from the null terminator delimiting the end of the JSON.
  50922. */
  50923. position: number;
  50924. }
  50925. /**
  50926. * Defines the specular data enclosed in the file.
  50927. * This corresponds to the version 1 of the data.
  50928. */
  50929. export interface EnvironmentTextureSpecularInfoV1 {
  50930. /**
  50931. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  50932. */
  50933. specularDataPosition?: number;
  50934. /**
  50935. * This contains all the images data needed to reconstruct the cubemap.
  50936. */
  50937. mipmaps: Array<BufferImageData>;
  50938. /**
  50939. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  50940. */
  50941. lodGenerationScale: number;
  50942. }
  50943. /**
  50944. * Sets of helpers addressing the serialization and deserialization of environment texture
  50945. * stored in a BabylonJS env file.
  50946. * Those files are usually stored as .env files.
  50947. */
  50948. export class EnvironmentTextureTools {
  50949. /**
  50950. * Magic number identifying the env file.
  50951. */
  50952. private static _MagicBytes;
  50953. /**
  50954. * Gets the environment info from an env file.
  50955. * @param data The array buffer containing the .env bytes.
  50956. * @returns the environment file info (the json header) if successfully parsed.
  50957. */
  50958. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  50959. /**
  50960. * Creates an environment texture from a loaded cube texture.
  50961. * @param texture defines the cube texture to convert in env file
  50962. * @return a promise containing the environment data if succesfull.
  50963. */
  50964. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  50965. /**
  50966. * Creates a JSON representation of the spherical data.
  50967. * @param texture defines the texture containing the polynomials
  50968. * @return the JSON representation of the spherical info
  50969. */
  50970. private static _CreateEnvTextureIrradiance;
  50971. /**
  50972. * Creates the ArrayBufferViews used for initializing environment texture image data.
  50973. * @param data the image data
  50974. * @param info parameters that determine what views will be created for accessing the underlying buffer
  50975. * @return the views described by info providing access to the underlying buffer
  50976. */
  50977. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  50978. /**
  50979. * Uploads the texture info contained in the env file to the GPU.
  50980. * @param texture defines the internal texture to upload to
  50981. * @param data defines the data to load
  50982. * @param info defines the texture info retrieved through the GetEnvInfo method
  50983. * @returns a promise
  50984. */
  50985. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  50986. private static _OnImageReadyAsync;
  50987. /**
  50988. * Uploads the levels of image data to the GPU.
  50989. * @param texture defines the internal texture to upload to
  50990. * @param imageData defines the array buffer views of image data [mipmap][face]
  50991. * @returns a promise
  50992. */
  50993. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  50994. /**
  50995. * Uploads spherical polynomials information to the texture.
  50996. * @param texture defines the texture we are trying to upload the information to
  50997. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  50998. */
  50999. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51000. /** @hidden */
  51001. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51002. }
  51003. }
  51004. declare module BABYLON {
  51005. /** @hidden */
  51006. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  51007. private _genericAttributeLocation;
  51008. private _varyingLocationCount;
  51009. private _varyingLocationMap;
  51010. private _replacements;
  51011. private _textureCount;
  51012. private _uniforms;
  51013. lineProcessor(line: string): string;
  51014. attributeProcessor(attribute: string): string;
  51015. varyingProcessor(varying: string, isFragment: boolean): string;
  51016. uniformProcessor(uniform: string): string;
  51017. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  51018. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  51019. }
  51020. }
  51021. declare module BABYLON {
  51022. /**
  51023. * Class used to inline functions in shader code
  51024. */
  51025. export class ShaderCodeInliner {
  51026. private static readonly _RegexpFindFunctionNameAndType;
  51027. private _sourceCode;
  51028. private _functionDescr;
  51029. private _numMaxIterations;
  51030. /** Gets or sets the token used to mark the functions to inline */
  51031. inlineToken: string;
  51032. /** Gets or sets the debug mode */
  51033. debug: boolean;
  51034. /** Gets the code after the inlining process */
  51035. get code(): string;
  51036. /**
  51037. * Initializes the inliner
  51038. * @param sourceCode shader code source to inline
  51039. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51040. */
  51041. constructor(sourceCode: string, numMaxIterations?: number);
  51042. /**
  51043. * Start the processing of the shader code
  51044. */
  51045. processCode(): void;
  51046. private _collectFunctions;
  51047. private _processInlining;
  51048. private _extractBetweenMarkers;
  51049. private _skipWhitespaces;
  51050. private _removeComments;
  51051. private _replaceFunctionCallsByCode;
  51052. private _findBackward;
  51053. private _escapeRegExp;
  51054. private _replaceNames;
  51055. }
  51056. }
  51057. declare module BABYLON {
  51058. /**
  51059. * Container for accessors for natively-stored mesh data buffers.
  51060. */
  51061. class NativeDataBuffer extends DataBuffer {
  51062. /**
  51063. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51064. */
  51065. nativeIndexBuffer?: any;
  51066. /**
  51067. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51068. */
  51069. nativeVertexBuffer?: any;
  51070. }
  51071. /** @hidden */
  51072. class NativeTexture extends InternalTexture {
  51073. getInternalTexture(): InternalTexture;
  51074. getViewCount(): number;
  51075. }
  51076. /** @hidden */
  51077. export class NativeEngine extends Engine {
  51078. private readonly _native;
  51079. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51080. private readonly INVALID_HANDLE;
  51081. getHardwareScalingLevel(): number;
  51082. constructor();
  51083. dispose(): void;
  51084. /**
  51085. * Can be used to override the current requestAnimationFrame requester.
  51086. * @hidden
  51087. */
  51088. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51089. /**
  51090. * Override default engine behavior.
  51091. * @param color
  51092. * @param backBuffer
  51093. * @param depth
  51094. * @param stencil
  51095. */
  51096. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51097. /**
  51098. * Gets host document
  51099. * @returns the host document object
  51100. */
  51101. getHostDocument(): Nullable<Document>;
  51102. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51103. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51104. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51105. recordVertexArrayObject(vertexBuffers: {
  51106. [key: string]: VertexBuffer;
  51107. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51108. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51109. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51110. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51111. /**
  51112. * Draw a list of indexed primitives
  51113. * @param fillMode defines the primitive to use
  51114. * @param indexStart defines the starting index
  51115. * @param indexCount defines the number of index to draw
  51116. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51117. */
  51118. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51119. /**
  51120. * Draw a list of unindexed primitives
  51121. * @param fillMode defines the primitive to use
  51122. * @param verticesStart defines the index of first vertex to draw
  51123. * @param verticesCount defines the count of vertices to draw
  51124. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51125. */
  51126. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51127. createPipelineContext(): IPipelineContext;
  51128. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51129. /** @hidden */
  51130. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51131. /** @hidden */
  51132. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51133. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51134. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51135. protected _setProgram(program: WebGLProgram): void;
  51136. _releaseEffect(effect: Effect): void;
  51137. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51138. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51139. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51140. bindSamplers(effect: Effect): void;
  51141. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51142. getRenderWidth(useScreen?: boolean): number;
  51143. getRenderHeight(useScreen?: boolean): number;
  51144. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51145. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51146. /**
  51147. * Set the z offset to apply to current rendering
  51148. * @param value defines the offset to apply
  51149. */
  51150. setZOffset(value: number): void;
  51151. /**
  51152. * Gets the current value of the zOffset
  51153. * @returns the current zOffset state
  51154. */
  51155. getZOffset(): number;
  51156. /**
  51157. * Enable or disable depth buffering
  51158. * @param enable defines the state to set
  51159. */
  51160. setDepthBuffer(enable: boolean): void;
  51161. /**
  51162. * Gets a boolean indicating if depth writing is enabled
  51163. * @returns the current depth writing state
  51164. */
  51165. getDepthWrite(): boolean;
  51166. /**
  51167. * Enable or disable depth writing
  51168. * @param enable defines the state to set
  51169. */
  51170. setDepthWrite(enable: boolean): void;
  51171. /**
  51172. * Enable or disable color writing
  51173. * @param enable defines the state to set
  51174. */
  51175. setColorWrite(enable: boolean): void;
  51176. /**
  51177. * Gets a boolean indicating if color writing is enabled
  51178. * @returns the current color writing state
  51179. */
  51180. getColorWrite(): boolean;
  51181. /**
  51182. * Sets alpha constants used by some alpha blending modes
  51183. * @param r defines the red component
  51184. * @param g defines the green component
  51185. * @param b defines the blue component
  51186. * @param a defines the alpha component
  51187. */
  51188. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51189. /**
  51190. * Sets the current alpha mode
  51191. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51192. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51193. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51194. */
  51195. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51196. /**
  51197. * Gets the current alpha mode
  51198. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51199. * @returns the current alpha mode
  51200. */
  51201. getAlphaMode(): number;
  51202. setInt(uniform: WebGLUniformLocation, int: number): void;
  51203. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51204. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51205. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51206. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51207. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51208. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51209. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51210. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51211. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51212. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51213. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51214. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51215. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51216. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51217. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51218. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51219. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51220. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51221. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51222. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51223. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51224. wipeCaches(bruteForce?: boolean): void;
  51225. _createTexture(): WebGLTexture;
  51226. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51227. /**
  51228. * Usually called from Texture.ts.
  51229. * Passed information to create a WebGLTexture
  51230. * @param url defines a value which contains one of the following:
  51231. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51232. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51233. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51234. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51235. * @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)
  51236. * @param scene needed for loading to the correct scene
  51237. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51238. * @param onLoad optional callback to be called upon successful completion
  51239. * @param onError optional callback to be called upon failure
  51240. * @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
  51241. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51242. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51243. * @param forcedExtension defines the extension to use to pick the right loader
  51244. * @param mimeType defines an optional mime type
  51245. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51246. */
  51247. 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;
  51248. /**
  51249. * Creates a cube texture
  51250. * @param rootUrl defines the url where the files to load is located
  51251. * @param scene defines the current scene
  51252. * @param files defines the list of files to load (1 per face)
  51253. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51254. * @param onLoad defines an optional callback raised when the texture is loaded
  51255. * @param onError defines an optional callback raised if there is an issue to load the texture
  51256. * @param format defines the format of the data
  51257. * @param forcedExtension defines the extension to use to pick the right loader
  51258. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51259. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51260. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51261. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51262. * @returns the cube texture as an InternalTexture
  51263. */
  51264. 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;
  51265. private _getSamplingFilter;
  51266. private static _GetNativeTextureFormat;
  51267. createRenderTargetTexture(size: number | {
  51268. width: number;
  51269. height: number;
  51270. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51271. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51272. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51273. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51274. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51275. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51276. /**
  51277. * Updates a dynamic vertex buffer.
  51278. * @param vertexBuffer the vertex buffer to update
  51279. * @param data the data used to update the vertex buffer
  51280. * @param byteOffset the byte offset of the data (optional)
  51281. * @param byteLength the byte length of the data (optional)
  51282. */
  51283. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51284. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51285. private _updateAnisotropicLevel;
  51286. private _getAddressMode;
  51287. /** @hidden */
  51288. _bindTexture(channel: number, texture: InternalTexture): void;
  51289. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51290. releaseEffects(): void;
  51291. /** @hidden */
  51292. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51293. /** @hidden */
  51294. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51295. /** @hidden */
  51296. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51297. /** @hidden */
  51298. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51299. }
  51300. }
  51301. declare module BABYLON {
  51302. /**
  51303. * Gather the list of clipboard event types as constants.
  51304. */
  51305. export class ClipboardEventTypes {
  51306. /**
  51307. * The clipboard event is fired when a copy command is active (pressed).
  51308. */
  51309. static readonly COPY: number;
  51310. /**
  51311. * The clipboard event is fired when a cut command is active (pressed).
  51312. */
  51313. static readonly CUT: number;
  51314. /**
  51315. * The clipboard event is fired when a paste command is active (pressed).
  51316. */
  51317. static readonly PASTE: number;
  51318. }
  51319. /**
  51320. * This class is used to store clipboard related info for the onClipboardObservable event.
  51321. */
  51322. export class ClipboardInfo {
  51323. /**
  51324. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51325. */
  51326. type: number;
  51327. /**
  51328. * Defines the related dom event
  51329. */
  51330. event: ClipboardEvent;
  51331. /**
  51332. *Creates an instance of ClipboardInfo.
  51333. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51334. * @param event Defines the related dom event
  51335. */
  51336. constructor(
  51337. /**
  51338. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51339. */
  51340. type: number,
  51341. /**
  51342. * Defines the related dom event
  51343. */
  51344. event: ClipboardEvent);
  51345. /**
  51346. * Get the clipboard event's type from the keycode.
  51347. * @param keyCode Defines the keyCode for the current keyboard event.
  51348. * @return {number}
  51349. */
  51350. static GetTypeFromCharacter(keyCode: number): number;
  51351. }
  51352. }
  51353. declare module BABYLON {
  51354. /**
  51355. * Google Daydream controller
  51356. */
  51357. export class DaydreamController extends WebVRController {
  51358. /**
  51359. * Base Url for the controller model.
  51360. */
  51361. static MODEL_BASE_URL: string;
  51362. /**
  51363. * File name for the controller model.
  51364. */
  51365. static MODEL_FILENAME: string;
  51366. /**
  51367. * Gamepad Id prefix used to identify Daydream Controller.
  51368. */
  51369. static readonly GAMEPAD_ID_PREFIX: string;
  51370. /**
  51371. * Creates a new DaydreamController from a gamepad
  51372. * @param vrGamepad the gamepad that the controller should be created from
  51373. */
  51374. constructor(vrGamepad: any);
  51375. /**
  51376. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51377. * @param scene scene in which to add meshes
  51378. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51379. */
  51380. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51381. /**
  51382. * Called once for each button that changed state since the last frame
  51383. * @param buttonIdx Which button index changed
  51384. * @param state New state of the button
  51385. * @param changes Which properties on the state changed since last frame
  51386. */
  51387. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51388. }
  51389. }
  51390. declare module BABYLON {
  51391. /**
  51392. * Gear VR Controller
  51393. */
  51394. export class GearVRController extends WebVRController {
  51395. /**
  51396. * Base Url for the controller model.
  51397. */
  51398. static MODEL_BASE_URL: string;
  51399. /**
  51400. * File name for the controller model.
  51401. */
  51402. static MODEL_FILENAME: string;
  51403. /**
  51404. * Gamepad Id prefix used to identify this controller.
  51405. */
  51406. static readonly GAMEPAD_ID_PREFIX: string;
  51407. private readonly _buttonIndexToObservableNameMap;
  51408. /**
  51409. * Creates a new GearVRController from a gamepad
  51410. * @param vrGamepad the gamepad that the controller should be created from
  51411. */
  51412. constructor(vrGamepad: any);
  51413. /**
  51414. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51415. * @param scene scene in which to add meshes
  51416. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51417. */
  51418. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51419. /**
  51420. * Called once for each button that changed state since the last frame
  51421. * @param buttonIdx Which button index changed
  51422. * @param state New state of the button
  51423. * @param changes Which properties on the state changed since last frame
  51424. */
  51425. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51426. }
  51427. }
  51428. declare module BABYLON {
  51429. /**
  51430. * Generic Controller
  51431. */
  51432. export class GenericController extends WebVRController {
  51433. /**
  51434. * Base Url for the controller model.
  51435. */
  51436. static readonly MODEL_BASE_URL: string;
  51437. /**
  51438. * File name for the controller model.
  51439. */
  51440. static readonly MODEL_FILENAME: string;
  51441. /**
  51442. * Creates a new GenericController from a gamepad
  51443. * @param vrGamepad the gamepad that the controller should be created from
  51444. */
  51445. constructor(vrGamepad: any);
  51446. /**
  51447. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51448. * @param scene scene in which to add meshes
  51449. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51450. */
  51451. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51452. /**
  51453. * Called once for each button that changed state since the last frame
  51454. * @param buttonIdx Which button index changed
  51455. * @param state New state of the button
  51456. * @param changes Which properties on the state changed since last frame
  51457. */
  51458. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51459. }
  51460. }
  51461. declare module BABYLON {
  51462. /**
  51463. * Oculus Touch Controller
  51464. */
  51465. export class OculusTouchController extends WebVRController {
  51466. /**
  51467. * Base Url for the controller model.
  51468. */
  51469. static MODEL_BASE_URL: string;
  51470. /**
  51471. * File name for the left controller model.
  51472. */
  51473. static MODEL_LEFT_FILENAME: string;
  51474. /**
  51475. * File name for the right controller model.
  51476. */
  51477. static MODEL_RIGHT_FILENAME: string;
  51478. /**
  51479. * Base Url for the Quest controller model.
  51480. */
  51481. static QUEST_MODEL_BASE_URL: string;
  51482. /**
  51483. * @hidden
  51484. * If the controllers are running on a device that needs the updated Quest controller models
  51485. */
  51486. static _IsQuest: boolean;
  51487. /**
  51488. * Fired when the secondary trigger on this controller is modified
  51489. */
  51490. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51491. /**
  51492. * Fired when the thumb rest on this controller is modified
  51493. */
  51494. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51495. /**
  51496. * Creates a new OculusTouchController from a gamepad
  51497. * @param vrGamepad the gamepad that the controller should be created from
  51498. */
  51499. constructor(vrGamepad: any);
  51500. /**
  51501. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51502. * @param scene scene in which to add meshes
  51503. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51504. */
  51505. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51506. /**
  51507. * Fired when the A button on this controller is modified
  51508. */
  51509. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51510. /**
  51511. * Fired when the B button on this controller is modified
  51512. */
  51513. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51514. /**
  51515. * Fired when the X button on this controller is modified
  51516. */
  51517. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51518. /**
  51519. * Fired when the Y button on this controller is modified
  51520. */
  51521. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51522. /**
  51523. * Called once for each button that changed state since the last frame
  51524. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51525. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51526. * 2) secondary trigger (same)
  51527. * 3) A (right) X (left), touch, pressed = value
  51528. * 4) B / Y
  51529. * 5) thumb rest
  51530. * @param buttonIdx Which button index changed
  51531. * @param state New state of the button
  51532. * @param changes Which properties on the state changed since last frame
  51533. */
  51534. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51535. }
  51536. }
  51537. declare module BABYLON {
  51538. /**
  51539. * Vive Controller
  51540. */
  51541. export class ViveController extends WebVRController {
  51542. /**
  51543. * Base Url for the controller model.
  51544. */
  51545. static MODEL_BASE_URL: string;
  51546. /**
  51547. * File name for the controller model.
  51548. */
  51549. static MODEL_FILENAME: string;
  51550. /**
  51551. * Creates a new ViveController from a gamepad
  51552. * @param vrGamepad the gamepad that the controller should be created from
  51553. */
  51554. constructor(vrGamepad: any);
  51555. /**
  51556. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51557. * @param scene scene in which to add meshes
  51558. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51559. */
  51560. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51561. /**
  51562. * Fired when the left button on this controller is modified
  51563. */
  51564. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51565. /**
  51566. * Fired when the right button on this controller is modified
  51567. */
  51568. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51569. /**
  51570. * Fired when the menu button on this controller is modified
  51571. */
  51572. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51573. /**
  51574. * Called once for each button that changed state since the last frame
  51575. * Vive mapping:
  51576. * 0: touchpad
  51577. * 1: trigger
  51578. * 2: left AND right buttons
  51579. * 3: menu button
  51580. * @param buttonIdx Which button index changed
  51581. * @param state New state of the button
  51582. * @param changes Which properties on the state changed since last frame
  51583. */
  51584. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51585. }
  51586. }
  51587. declare module BABYLON {
  51588. /**
  51589. * Defines the WindowsMotionController object that the state of the windows motion controller
  51590. */
  51591. export class WindowsMotionController extends WebVRController {
  51592. /**
  51593. * The base url used to load the left and right controller models
  51594. */
  51595. static MODEL_BASE_URL: string;
  51596. /**
  51597. * The name of the left controller model file
  51598. */
  51599. static MODEL_LEFT_FILENAME: string;
  51600. /**
  51601. * The name of the right controller model file
  51602. */
  51603. static MODEL_RIGHT_FILENAME: string;
  51604. /**
  51605. * The controller name prefix for this controller type
  51606. */
  51607. static readonly GAMEPAD_ID_PREFIX: string;
  51608. /**
  51609. * The controller id pattern for this controller type
  51610. */
  51611. private static readonly GAMEPAD_ID_PATTERN;
  51612. private _loadedMeshInfo;
  51613. protected readonly _mapping: {
  51614. buttons: string[];
  51615. buttonMeshNames: {
  51616. trigger: string;
  51617. menu: string;
  51618. grip: string;
  51619. thumbstick: string;
  51620. trackpad: string;
  51621. };
  51622. buttonObservableNames: {
  51623. trigger: string;
  51624. menu: string;
  51625. grip: string;
  51626. thumbstick: string;
  51627. trackpad: string;
  51628. };
  51629. axisMeshNames: string[];
  51630. pointingPoseMeshName: string;
  51631. };
  51632. /**
  51633. * Fired when the trackpad on this controller is clicked
  51634. */
  51635. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51636. /**
  51637. * Fired when the trackpad on this controller is modified
  51638. */
  51639. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51640. /**
  51641. * The current x and y values of this controller's trackpad
  51642. */
  51643. trackpad: StickValues;
  51644. /**
  51645. * Creates a new WindowsMotionController from a gamepad
  51646. * @param vrGamepad the gamepad that the controller should be created from
  51647. */
  51648. constructor(vrGamepad: any);
  51649. /**
  51650. * Fired when the trigger on this controller is modified
  51651. */
  51652. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51653. /**
  51654. * Fired when the menu button on this controller is modified
  51655. */
  51656. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51657. /**
  51658. * Fired when the grip button on this controller is modified
  51659. */
  51660. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51661. /**
  51662. * Fired when the thumbstick button on this controller is modified
  51663. */
  51664. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51665. /**
  51666. * Fired when the touchpad button on this controller is modified
  51667. */
  51668. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51669. /**
  51670. * Fired when the touchpad values on this controller are modified
  51671. */
  51672. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  51673. protected _updateTrackpad(): void;
  51674. /**
  51675. * Called once per frame by the engine.
  51676. */
  51677. update(): void;
  51678. /**
  51679. * Called once for each button that changed state since the last frame
  51680. * @param buttonIdx Which button index changed
  51681. * @param state New state of the button
  51682. * @param changes Which properties on the state changed since last frame
  51683. */
  51684. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51685. /**
  51686. * Moves the buttons on the controller mesh based on their current state
  51687. * @param buttonName the name of the button to move
  51688. * @param buttonValue the value of the button which determines the buttons new position
  51689. */
  51690. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  51691. /**
  51692. * Moves the axis on the controller mesh based on its current state
  51693. * @param axis the index of the axis
  51694. * @param axisValue the value of the axis which determines the meshes new position
  51695. * @hidden
  51696. */
  51697. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  51698. /**
  51699. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51700. * @param scene scene in which to add meshes
  51701. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51702. */
  51703. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  51704. /**
  51705. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  51706. * can be transformed by button presses and axes values, based on this._mapping.
  51707. *
  51708. * @param scene scene in which the meshes exist
  51709. * @param meshes list of meshes that make up the controller model to process
  51710. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  51711. */
  51712. private processModel;
  51713. private createMeshInfo;
  51714. /**
  51715. * Gets the ray of the controller in the direction the controller is pointing
  51716. * @param length the length the resulting ray should be
  51717. * @returns a ray in the direction the controller is pointing
  51718. */
  51719. getForwardRay(length?: number): Ray;
  51720. /**
  51721. * Disposes of the controller
  51722. */
  51723. dispose(): void;
  51724. }
  51725. /**
  51726. * This class represents a new windows motion controller in XR.
  51727. */
  51728. export class XRWindowsMotionController extends WindowsMotionController {
  51729. /**
  51730. * Changing the original WIndowsMotionController mapping to fir the new mapping
  51731. */
  51732. protected readonly _mapping: {
  51733. buttons: string[];
  51734. buttonMeshNames: {
  51735. trigger: string;
  51736. menu: string;
  51737. grip: string;
  51738. thumbstick: string;
  51739. trackpad: string;
  51740. };
  51741. buttonObservableNames: {
  51742. trigger: string;
  51743. menu: string;
  51744. grip: string;
  51745. thumbstick: string;
  51746. trackpad: string;
  51747. };
  51748. axisMeshNames: string[];
  51749. pointingPoseMeshName: string;
  51750. };
  51751. /**
  51752. * Construct a new XR-Based windows motion controller
  51753. *
  51754. * @param gamepadInfo the gamepad object from the browser
  51755. */
  51756. constructor(gamepadInfo: any);
  51757. /**
  51758. * holds the thumbstick values (X,Y)
  51759. */
  51760. thumbstickValues: StickValues;
  51761. /**
  51762. * Fired when the thumbstick on this controller is clicked
  51763. */
  51764. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  51765. /**
  51766. * Fired when the thumbstick on this controller is modified
  51767. */
  51768. onThumbstickValuesChangedObservable: Observable<StickValues>;
  51769. /**
  51770. * Fired when the touchpad button on this controller is modified
  51771. */
  51772. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51773. /**
  51774. * Fired when the touchpad values on this controller are modified
  51775. */
  51776. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51777. /**
  51778. * Fired when the thumbstick button on this controller is modified
  51779. * here to prevent breaking changes
  51780. */
  51781. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51782. /**
  51783. * updating the thumbstick(!) and not the trackpad.
  51784. * This is named this way due to the difference between WebVR and XR and to avoid
  51785. * changing the parent class.
  51786. */
  51787. protected _updateTrackpad(): void;
  51788. /**
  51789. * Disposes the class with joy
  51790. */
  51791. dispose(): void;
  51792. }
  51793. }
  51794. declare module BABYLON {
  51795. /**
  51796. * Class containing static functions to help procedurally build meshes
  51797. */
  51798. export class PolyhedronBuilder {
  51799. /**
  51800. * Creates a polyhedron mesh
  51801. * * 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
  51802. * * The parameter `size` (positive float, default 1) sets the polygon size
  51803. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51804. * * 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`
  51805. * * 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
  51806. * * 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)`)
  51807. * * 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
  51808. * * 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
  51809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51810. * * 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
  51811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51812. * @param name defines the name of the mesh
  51813. * @param options defines the options used to create the mesh
  51814. * @param scene defines the hosting scene
  51815. * @returns the polyhedron mesh
  51816. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51817. */
  51818. static CreatePolyhedron(name: string, options: {
  51819. type?: number;
  51820. size?: number;
  51821. sizeX?: number;
  51822. sizeY?: number;
  51823. sizeZ?: number;
  51824. custom?: any;
  51825. faceUV?: Vector4[];
  51826. faceColors?: Color4[];
  51827. flat?: boolean;
  51828. updatable?: boolean;
  51829. sideOrientation?: number;
  51830. frontUVs?: Vector4;
  51831. backUVs?: Vector4;
  51832. }, scene?: Nullable<Scene>): Mesh;
  51833. }
  51834. }
  51835. declare module BABYLON {
  51836. /**
  51837. * Gizmo that enables scaling a mesh along 3 axis
  51838. */
  51839. export class ScaleGizmo extends Gizmo {
  51840. /**
  51841. * Internal gizmo used for interactions on the x axis
  51842. */
  51843. xGizmo: AxisScaleGizmo;
  51844. /**
  51845. * Internal gizmo used for interactions on the y axis
  51846. */
  51847. yGizmo: AxisScaleGizmo;
  51848. /**
  51849. * Internal gizmo used for interactions on the z axis
  51850. */
  51851. zGizmo: AxisScaleGizmo;
  51852. /**
  51853. * Internal gizmo used to scale all axis equally
  51854. */
  51855. uniformScaleGizmo: AxisScaleGizmo;
  51856. private _meshAttached;
  51857. private _updateGizmoRotationToMatchAttachedMesh;
  51858. private _snapDistance;
  51859. private _scaleRatio;
  51860. private _uniformScalingMesh;
  51861. private _octahedron;
  51862. private _sensitivity;
  51863. /** Fires an event when any of it's sub gizmos are dragged */
  51864. onDragStartObservable: Observable<unknown>;
  51865. /** Fires an event when any of it's sub gizmos are released from dragging */
  51866. onDragEndObservable: Observable<unknown>;
  51867. get attachedMesh(): Nullable<AbstractMesh>;
  51868. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51869. /**
  51870. * Creates a ScaleGizmo
  51871. * @param gizmoLayer The utility layer the gizmo will be added to
  51872. */
  51873. constructor(gizmoLayer?: UtilityLayerRenderer);
  51874. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51875. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51876. /**
  51877. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51878. */
  51879. set snapDistance(value: number);
  51880. get snapDistance(): number;
  51881. /**
  51882. * Ratio for the scale of the gizmo (Default: 1)
  51883. */
  51884. set scaleRatio(value: number);
  51885. get scaleRatio(): number;
  51886. /**
  51887. * Sensitivity factor for dragging (Default: 1)
  51888. */
  51889. set sensitivity(value: number);
  51890. get sensitivity(): number;
  51891. /**
  51892. * Disposes of the gizmo
  51893. */
  51894. dispose(): void;
  51895. }
  51896. }
  51897. declare module BABYLON {
  51898. /**
  51899. * Single axis scale gizmo
  51900. */
  51901. export class AxisScaleGizmo extends Gizmo {
  51902. /**
  51903. * Drag behavior responsible for the gizmos dragging interactions
  51904. */
  51905. dragBehavior: PointerDragBehavior;
  51906. private _pointerObserver;
  51907. /**
  51908. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51909. */
  51910. snapDistance: number;
  51911. /**
  51912. * Event that fires each time the gizmo snaps to a new location.
  51913. * * snapDistance is the the change in distance
  51914. */
  51915. onSnapObservable: Observable<{
  51916. snapDistance: number;
  51917. }>;
  51918. /**
  51919. * If the scaling operation should be done on all axis (default: false)
  51920. */
  51921. uniformScaling: boolean;
  51922. /**
  51923. * Custom sensitivity value for the drag strength
  51924. */
  51925. sensitivity: number;
  51926. private _isEnabled;
  51927. private _parent;
  51928. private _arrow;
  51929. private _coloredMaterial;
  51930. private _hoverMaterial;
  51931. /**
  51932. * Creates an AxisScaleGizmo
  51933. * @param gizmoLayer The utility layer the gizmo will be added to
  51934. * @param dragAxis The axis which the gizmo will be able to scale on
  51935. * @param color The color of the gizmo
  51936. */
  51937. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51938. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51939. /**
  51940. * If the gizmo is enabled
  51941. */
  51942. set isEnabled(value: boolean);
  51943. get isEnabled(): boolean;
  51944. /**
  51945. * Disposes of the gizmo
  51946. */
  51947. dispose(): void;
  51948. /**
  51949. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51950. * @param mesh The mesh to replace the default mesh of the gizmo
  51951. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51952. */
  51953. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51954. }
  51955. }
  51956. declare module BABYLON {
  51957. /**
  51958. * Bounding box gizmo
  51959. */
  51960. export class BoundingBoxGizmo extends Gizmo {
  51961. private _lineBoundingBox;
  51962. private _rotateSpheresParent;
  51963. private _scaleBoxesParent;
  51964. private _boundingDimensions;
  51965. private _renderObserver;
  51966. private _pointerObserver;
  51967. private _scaleDragSpeed;
  51968. private _tmpQuaternion;
  51969. private _tmpVector;
  51970. private _tmpRotationMatrix;
  51971. /**
  51972. * 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)
  51973. */
  51974. ignoreChildren: boolean;
  51975. /**
  51976. * 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)
  51977. */
  51978. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  51979. /**
  51980. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  51981. */
  51982. rotationSphereSize: number;
  51983. /**
  51984. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  51985. */
  51986. scaleBoxSize: number;
  51987. /**
  51988. * 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)
  51989. */
  51990. fixedDragMeshScreenSize: boolean;
  51991. /**
  51992. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  51993. */
  51994. fixedDragMeshScreenSizeDistanceFactor: number;
  51995. /**
  51996. * Fired when a rotation sphere or scale box is dragged
  51997. */
  51998. onDragStartObservable: Observable<{}>;
  51999. /**
  52000. * Fired when a scale box is dragged
  52001. */
  52002. onScaleBoxDragObservable: Observable<{}>;
  52003. /**
  52004. * Fired when a scale box drag is ended
  52005. */
  52006. onScaleBoxDragEndObservable: Observable<{}>;
  52007. /**
  52008. * Fired when a rotation sphere is dragged
  52009. */
  52010. onRotationSphereDragObservable: Observable<{}>;
  52011. /**
  52012. * Fired when a rotation sphere drag is ended
  52013. */
  52014. onRotationSphereDragEndObservable: Observable<{}>;
  52015. /**
  52016. * 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)
  52017. */
  52018. scalePivot: Nullable<Vector3>;
  52019. /**
  52020. * Mesh used as a pivot to rotate the attached mesh
  52021. */
  52022. private _anchorMesh;
  52023. private _existingMeshScale;
  52024. private _dragMesh;
  52025. private pointerDragBehavior;
  52026. private coloredMaterial;
  52027. private hoverColoredMaterial;
  52028. /**
  52029. * Sets the color of the bounding box gizmo
  52030. * @param color the color to set
  52031. */
  52032. setColor(color: Color3): void;
  52033. /**
  52034. * Creates an BoundingBoxGizmo
  52035. * @param gizmoLayer The utility layer the gizmo will be added to
  52036. * @param color The color of the gizmo
  52037. */
  52038. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52039. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52040. private _selectNode;
  52041. /**
  52042. * Updates the bounding box information for the Gizmo
  52043. */
  52044. updateBoundingBox(): void;
  52045. private _updateRotationSpheres;
  52046. private _updateScaleBoxes;
  52047. /**
  52048. * Enables rotation on the specified axis and disables rotation on the others
  52049. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52050. */
  52051. setEnabledRotationAxis(axis: string): void;
  52052. /**
  52053. * Enables/disables scaling
  52054. * @param enable if scaling should be enabled
  52055. * @param homogeneousScaling defines if scaling should only be homogeneous
  52056. */
  52057. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52058. private _updateDummy;
  52059. /**
  52060. * Enables a pointer drag behavior on the bounding box of the gizmo
  52061. */
  52062. enableDragBehavior(): void;
  52063. /**
  52064. * Disposes of the gizmo
  52065. */
  52066. dispose(): void;
  52067. /**
  52068. * 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)
  52069. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52070. * @returns the bounding box mesh with the passed in mesh as a child
  52071. */
  52072. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52073. /**
  52074. * CustomMeshes are not supported by this gizmo
  52075. * @param mesh The mesh to replace the default mesh of the gizmo
  52076. */
  52077. setCustomMesh(mesh: Mesh): void;
  52078. }
  52079. }
  52080. declare module BABYLON {
  52081. /**
  52082. * Single plane rotation gizmo
  52083. */
  52084. export class PlaneRotationGizmo extends Gizmo {
  52085. /**
  52086. * Drag behavior responsible for the gizmos dragging interactions
  52087. */
  52088. dragBehavior: PointerDragBehavior;
  52089. private _pointerObserver;
  52090. /**
  52091. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52092. */
  52093. snapDistance: number;
  52094. /**
  52095. * Event that fires each time the gizmo snaps to a new location.
  52096. * * snapDistance is the the change in distance
  52097. */
  52098. onSnapObservable: Observable<{
  52099. snapDistance: number;
  52100. }>;
  52101. private _isEnabled;
  52102. private _parent;
  52103. /**
  52104. * Creates a PlaneRotationGizmo
  52105. * @param gizmoLayer The utility layer the gizmo will be added to
  52106. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52107. * @param color The color of the gizmo
  52108. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52109. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52110. */
  52111. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52112. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52113. /**
  52114. * If the gizmo is enabled
  52115. */
  52116. set isEnabled(value: boolean);
  52117. get isEnabled(): boolean;
  52118. /**
  52119. * Disposes of the gizmo
  52120. */
  52121. dispose(): void;
  52122. }
  52123. }
  52124. declare module BABYLON {
  52125. /**
  52126. * Gizmo that enables rotating a mesh along 3 axis
  52127. */
  52128. export class RotationGizmo extends Gizmo {
  52129. /**
  52130. * Internal gizmo used for interactions on the x axis
  52131. */
  52132. xGizmo: PlaneRotationGizmo;
  52133. /**
  52134. * Internal gizmo used for interactions on the y axis
  52135. */
  52136. yGizmo: PlaneRotationGizmo;
  52137. /**
  52138. * Internal gizmo used for interactions on the z axis
  52139. */
  52140. zGizmo: PlaneRotationGizmo;
  52141. /** Fires an event when any of it's sub gizmos are dragged */
  52142. onDragStartObservable: Observable<unknown>;
  52143. /** Fires an event when any of it's sub gizmos are released from dragging */
  52144. onDragEndObservable: Observable<unknown>;
  52145. private _meshAttached;
  52146. get attachedMesh(): Nullable<AbstractMesh>;
  52147. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52148. /**
  52149. * Creates a RotationGizmo
  52150. * @param gizmoLayer The utility layer the gizmo will be added to
  52151. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52152. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52153. */
  52154. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52155. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52156. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52157. /**
  52158. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52159. */
  52160. set snapDistance(value: number);
  52161. get snapDistance(): number;
  52162. /**
  52163. * Ratio for the scale of the gizmo (Default: 1)
  52164. */
  52165. set scaleRatio(value: number);
  52166. get scaleRatio(): number;
  52167. /**
  52168. * Disposes of the gizmo
  52169. */
  52170. dispose(): void;
  52171. /**
  52172. * CustomMeshes are not supported by this gizmo
  52173. * @param mesh The mesh to replace the default mesh of the gizmo
  52174. */
  52175. setCustomMesh(mesh: Mesh): void;
  52176. }
  52177. }
  52178. declare module BABYLON {
  52179. /**
  52180. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52181. */
  52182. export class GizmoManager implements IDisposable {
  52183. private scene;
  52184. /**
  52185. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52186. */
  52187. gizmos: {
  52188. positionGizmo: Nullable<PositionGizmo>;
  52189. rotationGizmo: Nullable<RotationGizmo>;
  52190. scaleGizmo: Nullable<ScaleGizmo>;
  52191. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52192. };
  52193. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52194. clearGizmoOnEmptyPointerEvent: boolean;
  52195. /** Fires an event when the manager is attached to a mesh */
  52196. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52197. private _gizmosEnabled;
  52198. private _pointerObserver;
  52199. private _attachedMesh;
  52200. private _boundingBoxColor;
  52201. private _defaultUtilityLayer;
  52202. private _defaultKeepDepthUtilityLayer;
  52203. /**
  52204. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52205. */
  52206. boundingBoxDragBehavior: SixDofDragBehavior;
  52207. /**
  52208. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52209. */
  52210. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52211. /**
  52212. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52213. */
  52214. usePointerToAttachGizmos: boolean;
  52215. /**
  52216. * Utility layer that the bounding box gizmo belongs to
  52217. */
  52218. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52219. /**
  52220. * Utility layer that all gizmos besides bounding box belong to
  52221. */
  52222. get utilityLayer(): UtilityLayerRenderer;
  52223. /**
  52224. * Instatiates a gizmo manager
  52225. * @param scene the scene to overlay the gizmos on top of
  52226. */
  52227. constructor(scene: Scene);
  52228. /**
  52229. * Attaches a set of gizmos to the specified mesh
  52230. * @param mesh The mesh the gizmo's should be attached to
  52231. */
  52232. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52233. /**
  52234. * If the position gizmo is enabled
  52235. */
  52236. set positionGizmoEnabled(value: boolean);
  52237. get positionGizmoEnabled(): boolean;
  52238. /**
  52239. * If the rotation gizmo is enabled
  52240. */
  52241. set rotationGizmoEnabled(value: boolean);
  52242. get rotationGizmoEnabled(): boolean;
  52243. /**
  52244. * If the scale gizmo is enabled
  52245. */
  52246. set scaleGizmoEnabled(value: boolean);
  52247. get scaleGizmoEnabled(): boolean;
  52248. /**
  52249. * If the boundingBox gizmo is enabled
  52250. */
  52251. set boundingBoxGizmoEnabled(value: boolean);
  52252. get boundingBoxGizmoEnabled(): boolean;
  52253. /**
  52254. * Disposes of the gizmo manager
  52255. */
  52256. dispose(): void;
  52257. }
  52258. }
  52259. declare module BABYLON {
  52260. /**
  52261. * A directional light is defined by a direction (what a surprise!).
  52262. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52263. * 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.
  52264. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52265. */
  52266. export class DirectionalLight extends ShadowLight {
  52267. private _shadowFrustumSize;
  52268. /**
  52269. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52270. */
  52271. get shadowFrustumSize(): number;
  52272. /**
  52273. * Specifies a fix frustum size for the shadow generation.
  52274. */
  52275. set shadowFrustumSize(value: number);
  52276. private _shadowOrthoScale;
  52277. /**
  52278. * Gets the shadow projection scale against the optimal computed one.
  52279. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52280. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52281. */
  52282. get shadowOrthoScale(): number;
  52283. /**
  52284. * Sets the shadow projection scale against the optimal computed one.
  52285. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52286. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52287. */
  52288. set shadowOrthoScale(value: number);
  52289. /**
  52290. * Automatically compute the projection matrix to best fit (including all the casters)
  52291. * on each frame.
  52292. */
  52293. autoUpdateExtends: boolean;
  52294. /**
  52295. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52296. * on each frame. autoUpdateExtends must be set to true for this to work
  52297. */
  52298. autoCalcShadowZBounds: boolean;
  52299. private _orthoLeft;
  52300. private _orthoRight;
  52301. private _orthoTop;
  52302. private _orthoBottom;
  52303. /**
  52304. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52305. * The directional light is emitted from everywhere in the given direction.
  52306. * It can cast shadows.
  52307. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52308. * @param name The friendly name of the light
  52309. * @param direction The direction of the light
  52310. * @param scene The scene the light belongs to
  52311. */
  52312. constructor(name: string, direction: Vector3, scene: Scene);
  52313. /**
  52314. * Returns the string "DirectionalLight".
  52315. * @return The class name
  52316. */
  52317. getClassName(): string;
  52318. /**
  52319. * Returns the integer 1.
  52320. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52321. */
  52322. getTypeID(): number;
  52323. /**
  52324. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52325. * Returns the DirectionalLight Shadow projection matrix.
  52326. */
  52327. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52328. /**
  52329. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52330. * Returns the DirectionalLight Shadow projection matrix.
  52331. */
  52332. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52333. /**
  52334. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52335. * Returns the DirectionalLight Shadow projection matrix.
  52336. */
  52337. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52338. protected _buildUniformLayout(): void;
  52339. /**
  52340. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52341. * @param effect The effect to update
  52342. * @param lightIndex The index of the light in the effect to update
  52343. * @returns The directional light
  52344. */
  52345. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52346. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52347. /**
  52348. * Gets the minZ 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 min for
  52353. * @returns the depth min z
  52354. */
  52355. getDepthMinZ(activeCamera: Camera): number;
  52356. /**
  52357. * Gets the maxZ used for shadow according to both the scene and the light.
  52358. *
  52359. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52360. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52361. * @param activeCamera The camera we are returning the max for
  52362. * @returns the depth max z
  52363. */
  52364. getDepthMaxZ(activeCamera: Camera): number;
  52365. /**
  52366. * Prepares the list of defines specific to the light type.
  52367. * @param defines the list of defines
  52368. * @param lightIndex defines the index of the light for the effect
  52369. */
  52370. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52371. }
  52372. }
  52373. declare module BABYLON {
  52374. /**
  52375. * Class containing static functions to help procedurally build meshes
  52376. */
  52377. export class HemisphereBuilder {
  52378. /**
  52379. * Creates a hemisphere mesh
  52380. * @param name defines the name of the mesh
  52381. * @param options defines the options used to create the mesh
  52382. * @param scene defines the hosting scene
  52383. * @returns the hemisphere mesh
  52384. */
  52385. static CreateHemisphere(name: string, options: {
  52386. segments?: number;
  52387. diameter?: number;
  52388. sideOrientation?: number;
  52389. }, scene: any): Mesh;
  52390. }
  52391. }
  52392. declare module BABYLON {
  52393. /**
  52394. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52395. * These values define a cone of light starting from the position, emitting toward the direction.
  52396. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52397. * and the exponent defines the speed of the decay of the light with distance (reach).
  52398. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52399. */
  52400. export class SpotLight extends ShadowLight {
  52401. private _angle;
  52402. private _innerAngle;
  52403. private _cosHalfAngle;
  52404. private _lightAngleScale;
  52405. private _lightAngleOffset;
  52406. /**
  52407. * Gets the cone angle of the spot light in Radians.
  52408. */
  52409. get angle(): number;
  52410. /**
  52411. * Sets the cone angle of the spot light in Radians.
  52412. */
  52413. set angle(value: number);
  52414. /**
  52415. * Only used in gltf falloff mode, this defines the angle where
  52416. * the directional falloff will start before cutting at angle which could be seen
  52417. * as outer angle.
  52418. */
  52419. get innerAngle(): number;
  52420. /**
  52421. * Only used in gltf falloff mode, this defines the angle where
  52422. * the directional falloff will start before cutting at angle which could be seen
  52423. * as outer angle.
  52424. */
  52425. set innerAngle(value: number);
  52426. private _shadowAngleScale;
  52427. /**
  52428. * Allows scaling the angle of the light for shadow generation only.
  52429. */
  52430. get shadowAngleScale(): number;
  52431. /**
  52432. * Allows scaling the angle of the light for shadow generation only.
  52433. */
  52434. set shadowAngleScale(value: number);
  52435. /**
  52436. * The light decay speed with the distance from the emission spot.
  52437. */
  52438. exponent: number;
  52439. private _projectionTextureMatrix;
  52440. /**
  52441. * Allows reading the projecton texture
  52442. */
  52443. get projectionTextureMatrix(): Matrix;
  52444. protected _projectionTextureLightNear: number;
  52445. /**
  52446. * Gets the near clip of the Spotlight for texture projection.
  52447. */
  52448. get projectionTextureLightNear(): number;
  52449. /**
  52450. * Sets the near clip of the Spotlight for texture projection.
  52451. */
  52452. set projectionTextureLightNear(value: number);
  52453. protected _projectionTextureLightFar: number;
  52454. /**
  52455. * Gets the far clip of the Spotlight for texture projection.
  52456. */
  52457. get projectionTextureLightFar(): number;
  52458. /**
  52459. * Sets the far clip of the Spotlight for texture projection.
  52460. */
  52461. set projectionTextureLightFar(value: number);
  52462. protected _projectionTextureUpDirection: Vector3;
  52463. /**
  52464. * Gets the Up vector of the Spotlight for texture projection.
  52465. */
  52466. get projectionTextureUpDirection(): Vector3;
  52467. /**
  52468. * Sets the Up vector of the Spotlight for texture projection.
  52469. */
  52470. set projectionTextureUpDirection(value: Vector3);
  52471. private _projectionTexture;
  52472. /**
  52473. * Gets the projection texture of the light.
  52474. */
  52475. get projectionTexture(): Nullable<BaseTexture>;
  52476. /**
  52477. * Sets the projection texture of the light.
  52478. */
  52479. set projectionTexture(value: Nullable<BaseTexture>);
  52480. private _projectionTextureViewLightDirty;
  52481. private _projectionTextureProjectionLightDirty;
  52482. private _projectionTextureDirty;
  52483. private _projectionTextureViewTargetVector;
  52484. private _projectionTextureViewLightMatrix;
  52485. private _projectionTextureProjectionLightMatrix;
  52486. private _projectionTextureScalingMatrix;
  52487. /**
  52488. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52489. * It can cast shadows.
  52490. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52491. * @param name The light friendly name
  52492. * @param position The position of the spot light in the scene
  52493. * @param direction The direction of the light in the scene
  52494. * @param angle The cone angle of the light in Radians
  52495. * @param exponent The light decay speed with the distance from the emission spot
  52496. * @param scene The scene the lights belongs to
  52497. */
  52498. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52499. /**
  52500. * Returns the string "SpotLight".
  52501. * @returns the class name
  52502. */
  52503. getClassName(): string;
  52504. /**
  52505. * Returns the integer 2.
  52506. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52507. */
  52508. getTypeID(): number;
  52509. /**
  52510. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52511. */
  52512. protected _setDirection(value: Vector3): void;
  52513. /**
  52514. * Overrides the position setter to recompute the projection texture view light Matrix.
  52515. */
  52516. protected _setPosition(value: Vector3): void;
  52517. /**
  52518. * 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.
  52519. * Returns the SpotLight.
  52520. */
  52521. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52522. protected _computeProjectionTextureViewLightMatrix(): void;
  52523. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52524. /**
  52525. * Main function for light texture projection matrix computing.
  52526. */
  52527. protected _computeProjectionTextureMatrix(): void;
  52528. protected _buildUniformLayout(): void;
  52529. private _computeAngleValues;
  52530. /**
  52531. * Sets the passed Effect "effect" with the Light textures.
  52532. * @param effect The effect to update
  52533. * @param lightIndex The index of the light in the effect to update
  52534. * @returns The light
  52535. */
  52536. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52537. /**
  52538. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52539. * @param effect The effect to update
  52540. * @param lightIndex The index of the light in the effect to update
  52541. * @returns The spot light
  52542. */
  52543. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52544. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52545. /**
  52546. * Disposes the light and the associated resources.
  52547. */
  52548. dispose(): void;
  52549. /**
  52550. * Prepares the list of defines specific to the light type.
  52551. * @param defines the list of defines
  52552. * @param lightIndex defines the index of the light for the effect
  52553. */
  52554. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52555. }
  52556. }
  52557. declare module BABYLON {
  52558. /**
  52559. * Gizmo that enables viewing a light
  52560. */
  52561. export class LightGizmo extends Gizmo {
  52562. private _lightMesh;
  52563. private _material;
  52564. private _cachedPosition;
  52565. private _cachedForward;
  52566. private _attachedMeshParent;
  52567. /**
  52568. * Creates a LightGizmo
  52569. * @param gizmoLayer The utility layer the gizmo will be added to
  52570. */
  52571. constructor(gizmoLayer?: UtilityLayerRenderer);
  52572. private _light;
  52573. /**
  52574. * The light that the gizmo is attached to
  52575. */
  52576. set light(light: Nullable<Light>);
  52577. get light(): Nullable<Light>;
  52578. /**
  52579. * Gets the material used to render the light gizmo
  52580. */
  52581. get material(): StandardMaterial;
  52582. /**
  52583. * @hidden
  52584. * Updates the gizmo to match the attached mesh's position/rotation
  52585. */
  52586. protected _update(): void;
  52587. private static _Scale;
  52588. /**
  52589. * Creates the lines for a light mesh
  52590. */
  52591. private static _CreateLightLines;
  52592. /**
  52593. * Disposes of the light gizmo
  52594. */
  52595. dispose(): void;
  52596. private static _CreateHemisphericLightMesh;
  52597. private static _CreatePointLightMesh;
  52598. private static _CreateSpotLightMesh;
  52599. private static _CreateDirectionalLightMesh;
  52600. }
  52601. }
  52602. declare module BABYLON {
  52603. /** @hidden */
  52604. export var backgroundFragmentDeclaration: {
  52605. name: string;
  52606. shader: string;
  52607. };
  52608. }
  52609. declare module BABYLON {
  52610. /** @hidden */
  52611. export var backgroundUboDeclaration: {
  52612. name: string;
  52613. shader: string;
  52614. };
  52615. }
  52616. declare module BABYLON {
  52617. /** @hidden */
  52618. export var backgroundPixelShader: {
  52619. name: string;
  52620. shader: string;
  52621. };
  52622. }
  52623. declare module BABYLON {
  52624. /** @hidden */
  52625. export var backgroundVertexDeclaration: {
  52626. name: string;
  52627. shader: string;
  52628. };
  52629. }
  52630. declare module BABYLON {
  52631. /** @hidden */
  52632. export var backgroundVertexShader: {
  52633. name: string;
  52634. shader: string;
  52635. };
  52636. }
  52637. declare module BABYLON {
  52638. /**
  52639. * Background material used to create an efficient environement around your scene.
  52640. */
  52641. export class BackgroundMaterial extends PushMaterial {
  52642. /**
  52643. * Standard reflectance value at parallel view angle.
  52644. */
  52645. static StandardReflectance0: number;
  52646. /**
  52647. * Standard reflectance value at grazing angle.
  52648. */
  52649. static StandardReflectance90: number;
  52650. protected _primaryColor: Color3;
  52651. /**
  52652. * Key light Color (multiply against the environement texture)
  52653. */
  52654. primaryColor: Color3;
  52655. protected __perceptualColor: Nullable<Color3>;
  52656. /**
  52657. * Experimental Internal Use Only.
  52658. *
  52659. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52660. * This acts as a helper to set the primary color to a more "human friendly" value.
  52661. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52662. * output color as close as possible from the chosen value.
  52663. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52664. * part of lighting setup.)
  52665. */
  52666. get _perceptualColor(): Nullable<Color3>;
  52667. set _perceptualColor(value: Nullable<Color3>);
  52668. protected _primaryColorShadowLevel: float;
  52669. /**
  52670. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52671. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52672. */
  52673. get primaryColorShadowLevel(): float;
  52674. set primaryColorShadowLevel(value: float);
  52675. protected _primaryColorHighlightLevel: float;
  52676. /**
  52677. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52678. * The primary color is used at the level chosen to define what the white area would look.
  52679. */
  52680. get primaryColorHighlightLevel(): float;
  52681. set primaryColorHighlightLevel(value: float);
  52682. protected _reflectionTexture: Nullable<BaseTexture>;
  52683. /**
  52684. * Reflection Texture used in the material.
  52685. * Should be author in a specific way for the best result (refer to the documentation).
  52686. */
  52687. reflectionTexture: Nullable<BaseTexture>;
  52688. protected _reflectionBlur: float;
  52689. /**
  52690. * Reflection Texture level of blur.
  52691. *
  52692. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52693. * texture twice.
  52694. */
  52695. reflectionBlur: float;
  52696. protected _diffuseTexture: Nullable<BaseTexture>;
  52697. /**
  52698. * Diffuse Texture used in the material.
  52699. * Should be author in a specific way for the best result (refer to the documentation).
  52700. */
  52701. diffuseTexture: Nullable<BaseTexture>;
  52702. protected _shadowLights: Nullable<IShadowLight[]>;
  52703. /**
  52704. * Specify the list of lights casting shadow on the material.
  52705. * All scene shadow lights will be included if null.
  52706. */
  52707. shadowLights: Nullable<IShadowLight[]>;
  52708. protected _shadowLevel: float;
  52709. /**
  52710. * Helps adjusting the shadow to a softer level if required.
  52711. * 0 means black shadows and 1 means no shadows.
  52712. */
  52713. shadowLevel: float;
  52714. protected _sceneCenter: Vector3;
  52715. /**
  52716. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52717. * It is usually zero but might be interesting to modify according to your setup.
  52718. */
  52719. sceneCenter: Vector3;
  52720. protected _opacityFresnel: boolean;
  52721. /**
  52722. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52723. * This helps ensuring a nice transition when the camera goes under the ground.
  52724. */
  52725. opacityFresnel: boolean;
  52726. protected _reflectionFresnel: boolean;
  52727. /**
  52728. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52729. * This helps adding a mirror texture on the ground.
  52730. */
  52731. reflectionFresnel: boolean;
  52732. protected _reflectionFalloffDistance: number;
  52733. /**
  52734. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52735. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52736. */
  52737. reflectionFalloffDistance: number;
  52738. protected _reflectionAmount: number;
  52739. /**
  52740. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52741. */
  52742. reflectionAmount: number;
  52743. protected _reflectionReflectance0: number;
  52744. /**
  52745. * This specifies the weight of the reflection at grazing angle.
  52746. */
  52747. reflectionReflectance0: number;
  52748. protected _reflectionReflectance90: number;
  52749. /**
  52750. * This specifies the weight of the reflection at a perpendicular point of view.
  52751. */
  52752. reflectionReflectance90: number;
  52753. /**
  52754. * Sets the reflection reflectance fresnel values according to the default standard
  52755. * empirically know to work well :-)
  52756. */
  52757. set reflectionStandardFresnelWeight(value: number);
  52758. protected _useRGBColor: boolean;
  52759. /**
  52760. * Helps to directly use the maps channels instead of their level.
  52761. */
  52762. useRGBColor: boolean;
  52763. protected _enableNoise: boolean;
  52764. /**
  52765. * This helps reducing the banding effect that could occur on the background.
  52766. */
  52767. enableNoise: boolean;
  52768. /**
  52769. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52770. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52771. * Recommended to be keep at 1.0 except for special cases.
  52772. */
  52773. get fovMultiplier(): number;
  52774. set fovMultiplier(value: number);
  52775. private _fovMultiplier;
  52776. /**
  52777. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52778. */
  52779. useEquirectangularFOV: boolean;
  52780. private _maxSimultaneousLights;
  52781. /**
  52782. * Number of Simultaneous lights allowed on the material.
  52783. */
  52784. maxSimultaneousLights: int;
  52785. /**
  52786. * Default configuration related to image processing available in the Background Material.
  52787. */
  52788. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52789. /**
  52790. * Keep track of the image processing observer to allow dispose and replace.
  52791. */
  52792. private _imageProcessingObserver;
  52793. /**
  52794. * Attaches a new image processing configuration to the PBR Material.
  52795. * @param configuration (if null the scene configuration will be use)
  52796. */
  52797. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52798. /**
  52799. * Gets the image processing configuration used either in this material.
  52800. */
  52801. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52802. /**
  52803. * Sets the Default image processing configuration used either in the this material.
  52804. *
  52805. * If sets to null, the scene one is in use.
  52806. */
  52807. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52808. /**
  52809. * Gets wether the color curves effect is enabled.
  52810. */
  52811. get cameraColorCurvesEnabled(): boolean;
  52812. /**
  52813. * Sets wether the color curves effect is enabled.
  52814. */
  52815. set cameraColorCurvesEnabled(value: boolean);
  52816. /**
  52817. * Gets wether the color grading effect is enabled.
  52818. */
  52819. get cameraColorGradingEnabled(): boolean;
  52820. /**
  52821. * Gets wether the color grading effect is enabled.
  52822. */
  52823. set cameraColorGradingEnabled(value: boolean);
  52824. /**
  52825. * Gets wether tonemapping is enabled or not.
  52826. */
  52827. get cameraToneMappingEnabled(): boolean;
  52828. /**
  52829. * Sets wether tonemapping is enabled or not
  52830. */
  52831. set cameraToneMappingEnabled(value: boolean);
  52832. /**
  52833. * The camera exposure used on this material.
  52834. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52835. * This corresponds to a photographic exposure.
  52836. */
  52837. get cameraExposure(): float;
  52838. /**
  52839. * The camera exposure used on this material.
  52840. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52841. * This corresponds to a photographic exposure.
  52842. */
  52843. set cameraExposure(value: float);
  52844. /**
  52845. * Gets The camera contrast used on this material.
  52846. */
  52847. get cameraContrast(): float;
  52848. /**
  52849. * Sets The camera contrast used on this material.
  52850. */
  52851. set cameraContrast(value: float);
  52852. /**
  52853. * Gets the Color Grading 2D Lookup Texture.
  52854. */
  52855. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52856. /**
  52857. * Sets the Color Grading 2D Lookup Texture.
  52858. */
  52859. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52860. /**
  52861. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52862. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52863. * 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;
  52864. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52865. */
  52866. get cameraColorCurves(): Nullable<ColorCurves>;
  52867. /**
  52868. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52869. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52870. * 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;
  52871. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52872. */
  52873. set cameraColorCurves(value: Nullable<ColorCurves>);
  52874. /**
  52875. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52876. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52877. */
  52878. switchToBGR: boolean;
  52879. private _renderTargets;
  52880. private _reflectionControls;
  52881. private _white;
  52882. private _primaryShadowColor;
  52883. private _primaryHighlightColor;
  52884. /**
  52885. * Instantiates a Background Material in the given scene
  52886. * @param name The friendly name of the material
  52887. * @param scene The scene to add the material to
  52888. */
  52889. constructor(name: string, scene: Scene);
  52890. /**
  52891. * Gets a boolean indicating that current material needs to register RTT
  52892. */
  52893. get hasRenderTargetTextures(): boolean;
  52894. /**
  52895. * The entire material has been created in order to prevent overdraw.
  52896. * @returns false
  52897. */
  52898. needAlphaTesting(): boolean;
  52899. /**
  52900. * The entire material has been created in order to prevent overdraw.
  52901. * @returns true if blending is enable
  52902. */
  52903. needAlphaBlending(): boolean;
  52904. /**
  52905. * Checks wether the material is ready to be rendered for a given mesh.
  52906. * @param mesh The mesh to render
  52907. * @param subMesh The submesh to check against
  52908. * @param useInstances Specify wether or not the material is used with instances
  52909. * @returns true if all the dependencies are ready (Textures, Effects...)
  52910. */
  52911. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52912. /**
  52913. * Compute the primary color according to the chosen perceptual color.
  52914. */
  52915. private _computePrimaryColorFromPerceptualColor;
  52916. /**
  52917. * Compute the highlights and shadow colors according to their chosen levels.
  52918. */
  52919. private _computePrimaryColors;
  52920. /**
  52921. * Build the uniform buffer used in the material.
  52922. */
  52923. buildUniformLayout(): void;
  52924. /**
  52925. * Unbind the material.
  52926. */
  52927. unbind(): void;
  52928. /**
  52929. * Bind only the world matrix to the material.
  52930. * @param world The world matrix to bind.
  52931. */
  52932. bindOnlyWorldMatrix(world: Matrix): void;
  52933. /**
  52934. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52935. * @param world The world matrix to bind.
  52936. * @param subMesh The submesh to bind for.
  52937. */
  52938. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52939. /**
  52940. * Checks to see if a texture is used in the material.
  52941. * @param texture - Base texture to use.
  52942. * @returns - Boolean specifying if a texture is used in the material.
  52943. */
  52944. hasTexture(texture: BaseTexture): boolean;
  52945. /**
  52946. * Dispose the material.
  52947. * @param forceDisposeEffect Force disposal of the associated effect.
  52948. * @param forceDisposeTextures Force disposal of the associated textures.
  52949. */
  52950. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52951. /**
  52952. * Clones the material.
  52953. * @param name The cloned name.
  52954. * @returns The cloned material.
  52955. */
  52956. clone(name: string): BackgroundMaterial;
  52957. /**
  52958. * Serializes the current material to its JSON representation.
  52959. * @returns The JSON representation.
  52960. */
  52961. serialize(): any;
  52962. /**
  52963. * Gets the class name of the material
  52964. * @returns "BackgroundMaterial"
  52965. */
  52966. getClassName(): string;
  52967. /**
  52968. * Parse a JSON input to create back a background material.
  52969. * @param source The JSON data to parse
  52970. * @param scene The scene to create the parsed material in
  52971. * @param rootUrl The root url of the assets the material depends upon
  52972. * @returns the instantiated BackgroundMaterial.
  52973. */
  52974. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  52975. }
  52976. }
  52977. declare module BABYLON {
  52978. /**
  52979. * Represents the different options available during the creation of
  52980. * a Environment helper.
  52981. *
  52982. * This can control the default ground, skybox and image processing setup of your scene.
  52983. */
  52984. export interface IEnvironmentHelperOptions {
  52985. /**
  52986. * Specifies whether or not to create a ground.
  52987. * True by default.
  52988. */
  52989. createGround: boolean;
  52990. /**
  52991. * Specifies the ground size.
  52992. * 15 by default.
  52993. */
  52994. groundSize: number;
  52995. /**
  52996. * The texture used on the ground for the main color.
  52997. * Comes from the BabylonJS CDN by default.
  52998. *
  52999. * Remarks: Can be either a texture or a url.
  53000. */
  53001. groundTexture: string | BaseTexture;
  53002. /**
  53003. * The color mixed in the ground texture by default.
  53004. * BabylonJS clearColor by default.
  53005. */
  53006. groundColor: Color3;
  53007. /**
  53008. * Specifies the ground opacity.
  53009. * 1 by default.
  53010. */
  53011. groundOpacity: number;
  53012. /**
  53013. * Enables the ground to receive shadows.
  53014. * True by default.
  53015. */
  53016. enableGroundShadow: boolean;
  53017. /**
  53018. * Helps preventing the shadow to be fully black on the ground.
  53019. * 0.5 by default.
  53020. */
  53021. groundShadowLevel: number;
  53022. /**
  53023. * Creates a mirror texture attach to the ground.
  53024. * false by default.
  53025. */
  53026. enableGroundMirror: boolean;
  53027. /**
  53028. * Specifies the ground mirror size ratio.
  53029. * 0.3 by default as the default kernel is 64.
  53030. */
  53031. groundMirrorSizeRatio: number;
  53032. /**
  53033. * Specifies the ground mirror blur kernel size.
  53034. * 64 by default.
  53035. */
  53036. groundMirrorBlurKernel: number;
  53037. /**
  53038. * Specifies the ground mirror visibility amount.
  53039. * 1 by default
  53040. */
  53041. groundMirrorAmount: number;
  53042. /**
  53043. * Specifies the ground mirror reflectance weight.
  53044. * This uses the standard weight of the background material to setup the fresnel effect
  53045. * of the mirror.
  53046. * 1 by default.
  53047. */
  53048. groundMirrorFresnelWeight: number;
  53049. /**
  53050. * Specifies the ground mirror Falloff distance.
  53051. * This can helps reducing the size of the reflection.
  53052. * 0 by Default.
  53053. */
  53054. groundMirrorFallOffDistance: number;
  53055. /**
  53056. * Specifies the ground mirror texture type.
  53057. * Unsigned Int by Default.
  53058. */
  53059. groundMirrorTextureType: number;
  53060. /**
  53061. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53062. * the shown objects.
  53063. */
  53064. groundYBias: number;
  53065. /**
  53066. * Specifies whether or not to create a skybox.
  53067. * True by default.
  53068. */
  53069. createSkybox: boolean;
  53070. /**
  53071. * Specifies the skybox size.
  53072. * 20 by default.
  53073. */
  53074. skyboxSize: number;
  53075. /**
  53076. * The texture used on the skybox for the main color.
  53077. * Comes from the BabylonJS CDN by default.
  53078. *
  53079. * Remarks: Can be either a texture or a url.
  53080. */
  53081. skyboxTexture: string | BaseTexture;
  53082. /**
  53083. * The color mixed in the skybox texture by default.
  53084. * BabylonJS clearColor by default.
  53085. */
  53086. skyboxColor: Color3;
  53087. /**
  53088. * The background rotation around the Y axis of the scene.
  53089. * This helps aligning the key lights of your scene with the background.
  53090. * 0 by default.
  53091. */
  53092. backgroundYRotation: number;
  53093. /**
  53094. * Compute automatically the size of the elements to best fit with the scene.
  53095. */
  53096. sizeAuto: boolean;
  53097. /**
  53098. * Default position of the rootMesh if autoSize is not true.
  53099. */
  53100. rootPosition: Vector3;
  53101. /**
  53102. * Sets up the image processing in the scene.
  53103. * true by default.
  53104. */
  53105. setupImageProcessing: boolean;
  53106. /**
  53107. * The texture used as your environment texture in the scene.
  53108. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53109. *
  53110. * Remarks: Can be either a texture or a url.
  53111. */
  53112. environmentTexture: string | BaseTexture;
  53113. /**
  53114. * The value of the exposure to apply to the scene.
  53115. * 0.6 by default if setupImageProcessing is true.
  53116. */
  53117. cameraExposure: number;
  53118. /**
  53119. * The value of the contrast to apply to the scene.
  53120. * 1.6 by default if setupImageProcessing is true.
  53121. */
  53122. cameraContrast: number;
  53123. /**
  53124. * Specifies whether or not tonemapping should be enabled in the scene.
  53125. * true by default if setupImageProcessing is true.
  53126. */
  53127. toneMappingEnabled: boolean;
  53128. }
  53129. /**
  53130. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53131. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53132. * It also helps with the default setup of your imageProcessing configuration.
  53133. */
  53134. export class EnvironmentHelper {
  53135. /**
  53136. * Default ground texture URL.
  53137. */
  53138. private static _groundTextureCDNUrl;
  53139. /**
  53140. * Default skybox texture URL.
  53141. */
  53142. private static _skyboxTextureCDNUrl;
  53143. /**
  53144. * Default environment texture URL.
  53145. */
  53146. private static _environmentTextureCDNUrl;
  53147. /**
  53148. * Creates the default options for the helper.
  53149. */
  53150. private static _getDefaultOptions;
  53151. private _rootMesh;
  53152. /**
  53153. * Gets the root mesh created by the helper.
  53154. */
  53155. get rootMesh(): Mesh;
  53156. private _skybox;
  53157. /**
  53158. * Gets the skybox created by the helper.
  53159. */
  53160. get skybox(): Nullable<Mesh>;
  53161. private _skyboxTexture;
  53162. /**
  53163. * Gets the skybox texture created by the helper.
  53164. */
  53165. get skyboxTexture(): Nullable<BaseTexture>;
  53166. private _skyboxMaterial;
  53167. /**
  53168. * Gets the skybox material created by the helper.
  53169. */
  53170. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53171. private _ground;
  53172. /**
  53173. * Gets the ground mesh created by the helper.
  53174. */
  53175. get ground(): Nullable<Mesh>;
  53176. private _groundTexture;
  53177. /**
  53178. * Gets the ground texture created by the helper.
  53179. */
  53180. get groundTexture(): Nullable<BaseTexture>;
  53181. private _groundMirror;
  53182. /**
  53183. * Gets the ground mirror created by the helper.
  53184. */
  53185. get groundMirror(): Nullable<MirrorTexture>;
  53186. /**
  53187. * Gets the ground mirror render list to helps pushing the meshes
  53188. * you wish in the ground reflection.
  53189. */
  53190. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53191. private _groundMaterial;
  53192. /**
  53193. * Gets the ground material created by the helper.
  53194. */
  53195. get groundMaterial(): Nullable<BackgroundMaterial>;
  53196. /**
  53197. * Stores the creation options.
  53198. */
  53199. private readonly _scene;
  53200. private _options;
  53201. /**
  53202. * This observable will be notified with any error during the creation of the environment,
  53203. * mainly texture creation errors.
  53204. */
  53205. onErrorObservable: Observable<{
  53206. message?: string;
  53207. exception?: any;
  53208. }>;
  53209. /**
  53210. * constructor
  53211. * @param options Defines the options we want to customize the helper
  53212. * @param scene The scene to add the material to
  53213. */
  53214. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53215. /**
  53216. * Updates the background according to the new options
  53217. * @param options
  53218. */
  53219. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53220. /**
  53221. * Sets the primary color of all the available elements.
  53222. * @param color the main color to affect to the ground and the background
  53223. */
  53224. setMainColor(color: Color3): void;
  53225. /**
  53226. * Setup the image processing according to the specified options.
  53227. */
  53228. private _setupImageProcessing;
  53229. /**
  53230. * Setup the environment texture according to the specified options.
  53231. */
  53232. private _setupEnvironmentTexture;
  53233. /**
  53234. * Setup the background according to the specified options.
  53235. */
  53236. private _setupBackground;
  53237. /**
  53238. * Get the scene sizes according to the setup.
  53239. */
  53240. private _getSceneSize;
  53241. /**
  53242. * Setup the ground according to the specified options.
  53243. */
  53244. private _setupGround;
  53245. /**
  53246. * Setup the ground material according to the specified options.
  53247. */
  53248. private _setupGroundMaterial;
  53249. /**
  53250. * Setup the ground diffuse texture according to the specified options.
  53251. */
  53252. private _setupGroundDiffuseTexture;
  53253. /**
  53254. * Setup the ground mirror texture according to the specified options.
  53255. */
  53256. private _setupGroundMirrorTexture;
  53257. /**
  53258. * Setup the ground to receive the mirror texture.
  53259. */
  53260. private _setupMirrorInGroundMaterial;
  53261. /**
  53262. * Setup the skybox according to the specified options.
  53263. */
  53264. private _setupSkybox;
  53265. /**
  53266. * Setup the skybox material according to the specified options.
  53267. */
  53268. private _setupSkyboxMaterial;
  53269. /**
  53270. * Setup the skybox reflection texture according to the specified options.
  53271. */
  53272. private _setupSkyboxReflectionTexture;
  53273. private _errorHandler;
  53274. /**
  53275. * Dispose all the elements created by the Helper.
  53276. */
  53277. dispose(): void;
  53278. }
  53279. }
  53280. declare module BABYLON {
  53281. /**
  53282. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53283. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53284. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53285. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53286. */
  53287. export class PhotoDome extends TransformNode {
  53288. /**
  53289. * Define the image as a Monoscopic panoramic 360 image.
  53290. */
  53291. static readonly MODE_MONOSCOPIC: number;
  53292. /**
  53293. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53294. */
  53295. static readonly MODE_TOPBOTTOM: number;
  53296. /**
  53297. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53298. */
  53299. static readonly MODE_SIDEBYSIDE: number;
  53300. private _useDirectMapping;
  53301. /**
  53302. * The texture being displayed on the sphere
  53303. */
  53304. protected _photoTexture: Texture;
  53305. /**
  53306. * Gets or sets the texture being displayed on the sphere
  53307. */
  53308. get photoTexture(): Texture;
  53309. set photoTexture(value: Texture);
  53310. /**
  53311. * Observable raised when an error occured while loading the 360 image
  53312. */
  53313. onLoadErrorObservable: Observable<string>;
  53314. /**
  53315. * The skybox material
  53316. */
  53317. protected _material: BackgroundMaterial;
  53318. /**
  53319. * The surface used for the skybox
  53320. */
  53321. protected _mesh: Mesh;
  53322. /**
  53323. * Gets the mesh used for the skybox.
  53324. */
  53325. get mesh(): Mesh;
  53326. /**
  53327. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53328. * Also see the options.resolution property.
  53329. */
  53330. get fovMultiplier(): number;
  53331. set fovMultiplier(value: number);
  53332. private _imageMode;
  53333. /**
  53334. * Gets or set the current video mode for the video. It can be:
  53335. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53336. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53337. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53338. */
  53339. get imageMode(): number;
  53340. set imageMode(value: number);
  53341. /**
  53342. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53343. * @param name Element's name, child elements will append suffixes for their own names.
  53344. * @param urlsOfPhoto defines the url of the photo to display
  53345. * @param options defines an object containing optional or exposed sub element properties
  53346. * @param onError defines a callback called when an error occured while loading the texture
  53347. */
  53348. constructor(name: string, urlOfPhoto: string, options: {
  53349. resolution?: number;
  53350. size?: number;
  53351. useDirectMapping?: boolean;
  53352. faceForward?: boolean;
  53353. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53354. private _onBeforeCameraRenderObserver;
  53355. private _changeImageMode;
  53356. /**
  53357. * Releases resources associated with this node.
  53358. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53359. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53360. */
  53361. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53362. }
  53363. }
  53364. declare module BABYLON {
  53365. /**
  53366. * Class used to host RGBD texture specific utilities
  53367. */
  53368. export class RGBDTextureTools {
  53369. /**
  53370. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53371. * @param texture the texture to expand.
  53372. */
  53373. static ExpandRGBDTexture(texture: Texture): void;
  53374. }
  53375. }
  53376. declare module BABYLON {
  53377. /**
  53378. * Class used to host texture specific utilities
  53379. */
  53380. export class BRDFTextureTools {
  53381. /**
  53382. * Prevents texture cache collision
  53383. */
  53384. private static _instanceNumber;
  53385. /**
  53386. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53387. * @param scene defines the hosting scene
  53388. * @returns the environment BRDF texture
  53389. */
  53390. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53391. private static _environmentBRDFBase64Texture;
  53392. }
  53393. }
  53394. declare module BABYLON {
  53395. /**
  53396. * @hidden
  53397. */
  53398. export interface IMaterialClearCoatDefines {
  53399. CLEARCOAT: boolean;
  53400. CLEARCOAT_DEFAULTIOR: boolean;
  53401. CLEARCOAT_TEXTURE: boolean;
  53402. CLEARCOAT_TEXTUREDIRECTUV: number;
  53403. CLEARCOAT_BUMP: boolean;
  53404. CLEARCOAT_BUMPDIRECTUV: number;
  53405. CLEARCOAT_TINT: boolean;
  53406. CLEARCOAT_TINT_TEXTURE: boolean;
  53407. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53408. /** @hidden */
  53409. _areTexturesDirty: boolean;
  53410. }
  53411. /**
  53412. * Define the code related to the clear coat parameters of the pbr material.
  53413. */
  53414. export class PBRClearCoatConfiguration {
  53415. /**
  53416. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53417. * The default fits with a polyurethane material.
  53418. */
  53419. private static readonly _DefaultIndexOfRefraction;
  53420. private _isEnabled;
  53421. /**
  53422. * Defines if the clear coat is enabled in the material.
  53423. */
  53424. isEnabled: boolean;
  53425. /**
  53426. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53427. */
  53428. intensity: number;
  53429. /**
  53430. * Defines the clear coat layer roughness.
  53431. */
  53432. roughness: number;
  53433. private _indexOfRefraction;
  53434. /**
  53435. * Defines the index of refraction of the clear coat.
  53436. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53437. * The default fits with a polyurethane material.
  53438. * Changing the default value is more performance intensive.
  53439. */
  53440. indexOfRefraction: number;
  53441. private _texture;
  53442. /**
  53443. * Stores the clear coat values in a texture.
  53444. */
  53445. texture: Nullable<BaseTexture>;
  53446. private _bumpTexture;
  53447. /**
  53448. * Define the clear coat specific bump texture.
  53449. */
  53450. bumpTexture: Nullable<BaseTexture>;
  53451. private _isTintEnabled;
  53452. /**
  53453. * Defines if the clear coat tint is enabled in the material.
  53454. */
  53455. isTintEnabled: boolean;
  53456. /**
  53457. * Defines the clear coat tint of the material.
  53458. * This is only use if tint is enabled
  53459. */
  53460. tintColor: Color3;
  53461. /**
  53462. * Defines the distance at which the tint color should be found in the
  53463. * clear coat media.
  53464. * This is only use if tint is enabled
  53465. */
  53466. tintColorAtDistance: number;
  53467. /**
  53468. * Defines the clear coat layer thickness.
  53469. * This is only use if tint is enabled
  53470. */
  53471. tintThickness: number;
  53472. private _tintTexture;
  53473. /**
  53474. * Stores the clear tint values in a texture.
  53475. * rgb is tint
  53476. * a is a thickness factor
  53477. */
  53478. tintTexture: Nullable<BaseTexture>;
  53479. /** @hidden */
  53480. private _internalMarkAllSubMeshesAsTexturesDirty;
  53481. /** @hidden */
  53482. _markAllSubMeshesAsTexturesDirty(): void;
  53483. /**
  53484. * Instantiate a new istance of clear coat configuration.
  53485. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53486. */
  53487. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53488. /**
  53489. * Gets wehter the submesh is ready to be used or not.
  53490. * @param defines the list of "defines" to update.
  53491. * @param scene defines the scene the material belongs to.
  53492. * @param engine defines the engine the material belongs to.
  53493. * @param disableBumpMap defines wether the material disables bump or not.
  53494. * @returns - boolean indicating that the submesh is ready or not.
  53495. */
  53496. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53497. /**
  53498. * Checks to see if a texture is used in the material.
  53499. * @param defines the list of "defines" to update.
  53500. * @param scene defines the scene to the material belongs to.
  53501. */
  53502. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53503. /**
  53504. * Binds the material data.
  53505. * @param uniformBuffer defines the Uniform buffer to fill in.
  53506. * @param scene defines the scene the material belongs to.
  53507. * @param engine defines the engine the material belongs to.
  53508. * @param disableBumpMap defines wether the material disables bump or not.
  53509. * @param isFrozen defines wether the material is frozen or not.
  53510. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53511. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53512. */
  53513. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53514. /**
  53515. * Checks to see if a texture is used in the material.
  53516. * @param texture - Base texture to use.
  53517. * @returns - Boolean specifying if a texture is used in the material.
  53518. */
  53519. hasTexture(texture: BaseTexture): boolean;
  53520. /**
  53521. * Returns an array of the actively used textures.
  53522. * @param activeTextures Array of BaseTextures
  53523. */
  53524. getActiveTextures(activeTextures: BaseTexture[]): void;
  53525. /**
  53526. * Returns the animatable textures.
  53527. * @param animatables Array of animatable textures.
  53528. */
  53529. getAnimatables(animatables: IAnimatable[]): void;
  53530. /**
  53531. * Disposes the resources of the material.
  53532. * @param forceDisposeTextures - Forces the disposal of all textures.
  53533. */
  53534. dispose(forceDisposeTextures?: boolean): void;
  53535. /**
  53536. * Get the current class name of the texture useful for serialization or dynamic coding.
  53537. * @returns "PBRClearCoatConfiguration"
  53538. */
  53539. getClassName(): string;
  53540. /**
  53541. * Add fallbacks to the effect fallbacks list.
  53542. * @param defines defines the Base texture to use.
  53543. * @param fallbacks defines the current fallback list.
  53544. * @param currentRank defines the current fallback rank.
  53545. * @returns the new fallback rank.
  53546. */
  53547. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53548. /**
  53549. * Add the required uniforms to the current list.
  53550. * @param uniforms defines the current uniform list.
  53551. */
  53552. static AddUniforms(uniforms: string[]): void;
  53553. /**
  53554. * Add the required samplers to the current list.
  53555. * @param samplers defines the current sampler list.
  53556. */
  53557. static AddSamplers(samplers: string[]): void;
  53558. /**
  53559. * Add the required uniforms to the current buffer.
  53560. * @param uniformBuffer defines the current uniform buffer.
  53561. */
  53562. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53563. /**
  53564. * Makes a duplicate of the current configuration into another one.
  53565. * @param clearCoatConfiguration define the config where to copy the info
  53566. */
  53567. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  53568. /**
  53569. * Serializes this clear coat configuration.
  53570. * @returns - An object with the serialized config.
  53571. */
  53572. serialize(): any;
  53573. /**
  53574. * Parses a anisotropy Configuration from a serialized object.
  53575. * @param source - Serialized object.
  53576. * @param scene Defines the scene we are parsing for
  53577. * @param rootUrl Defines the rootUrl to load from
  53578. */
  53579. parse(source: any, scene: Scene, rootUrl: string): void;
  53580. }
  53581. }
  53582. declare module BABYLON {
  53583. /**
  53584. * @hidden
  53585. */
  53586. export interface IMaterialAnisotropicDefines {
  53587. ANISOTROPIC: boolean;
  53588. ANISOTROPIC_TEXTURE: boolean;
  53589. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53590. MAINUV1: boolean;
  53591. _areTexturesDirty: boolean;
  53592. _needUVs: boolean;
  53593. }
  53594. /**
  53595. * Define the code related to the anisotropic parameters of the pbr material.
  53596. */
  53597. export class PBRAnisotropicConfiguration {
  53598. private _isEnabled;
  53599. /**
  53600. * Defines if the anisotropy is enabled in the material.
  53601. */
  53602. isEnabled: boolean;
  53603. /**
  53604. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  53605. */
  53606. intensity: number;
  53607. /**
  53608. * Defines if the effect is along the tangents, bitangents or in between.
  53609. * By default, the effect is "strectching" the highlights along the tangents.
  53610. */
  53611. direction: Vector2;
  53612. private _texture;
  53613. /**
  53614. * Stores the anisotropy values in a texture.
  53615. * rg is direction (like normal from -1 to 1)
  53616. * b is a intensity
  53617. */
  53618. texture: Nullable<BaseTexture>;
  53619. /** @hidden */
  53620. private _internalMarkAllSubMeshesAsTexturesDirty;
  53621. /** @hidden */
  53622. _markAllSubMeshesAsTexturesDirty(): void;
  53623. /**
  53624. * Instantiate a new istance of anisotropy configuration.
  53625. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53626. */
  53627. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53628. /**
  53629. * Specifies that the submesh is ready to be used.
  53630. * @param defines the list of "defines" to update.
  53631. * @param scene defines the scene the material belongs to.
  53632. * @returns - boolean indicating that the submesh is ready or not.
  53633. */
  53634. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53635. /**
  53636. * Checks to see if a texture is used in the material.
  53637. * @param defines the list of "defines" to update.
  53638. * @param mesh the mesh we are preparing the defines for.
  53639. * @param scene defines the scene the material belongs to.
  53640. */
  53641. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53642. /**
  53643. * Binds the material data.
  53644. * @param uniformBuffer defines the Uniform buffer to fill in.
  53645. * @param scene defines the scene the material belongs to.
  53646. * @param isFrozen defines wether the material is frozen or not.
  53647. */
  53648. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53649. /**
  53650. * Checks to see if a texture is used in the material.
  53651. * @param texture - Base texture to use.
  53652. * @returns - Boolean specifying if a texture is used in the material.
  53653. */
  53654. hasTexture(texture: BaseTexture): boolean;
  53655. /**
  53656. * Returns an array of the actively used textures.
  53657. * @param activeTextures Array of BaseTextures
  53658. */
  53659. getActiveTextures(activeTextures: BaseTexture[]): void;
  53660. /**
  53661. * Returns the animatable textures.
  53662. * @param animatables Array of animatable textures.
  53663. */
  53664. getAnimatables(animatables: IAnimatable[]): void;
  53665. /**
  53666. * Disposes the resources of the material.
  53667. * @param forceDisposeTextures - Forces the disposal of all textures.
  53668. */
  53669. dispose(forceDisposeTextures?: boolean): void;
  53670. /**
  53671. * Get the current class name of the texture useful for serialization or dynamic coding.
  53672. * @returns "PBRAnisotropicConfiguration"
  53673. */
  53674. getClassName(): string;
  53675. /**
  53676. * Add fallbacks to the effect fallbacks list.
  53677. * @param defines defines the Base texture to use.
  53678. * @param fallbacks defines the current fallback list.
  53679. * @param currentRank defines the current fallback rank.
  53680. * @returns the new fallback rank.
  53681. */
  53682. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53683. /**
  53684. * Add the required uniforms to the current list.
  53685. * @param uniforms defines the current uniform list.
  53686. */
  53687. static AddUniforms(uniforms: string[]): void;
  53688. /**
  53689. * Add the required uniforms to the current buffer.
  53690. * @param uniformBuffer defines the current uniform buffer.
  53691. */
  53692. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53693. /**
  53694. * Add the required samplers to the current list.
  53695. * @param samplers defines the current sampler list.
  53696. */
  53697. static AddSamplers(samplers: string[]): void;
  53698. /**
  53699. * Makes a duplicate of the current configuration into another one.
  53700. * @param anisotropicConfiguration define the config where to copy the info
  53701. */
  53702. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53703. /**
  53704. * Serializes this anisotropy configuration.
  53705. * @returns - An object with the serialized config.
  53706. */
  53707. serialize(): any;
  53708. /**
  53709. * Parses a anisotropy Configuration from a serialized object.
  53710. * @param source - Serialized object.
  53711. * @param scene Defines the scene we are parsing for
  53712. * @param rootUrl Defines the rootUrl to load from
  53713. */
  53714. parse(source: any, scene: Scene, rootUrl: string): void;
  53715. }
  53716. }
  53717. declare module BABYLON {
  53718. /**
  53719. * @hidden
  53720. */
  53721. export interface IMaterialBRDFDefines {
  53722. BRDF_V_HEIGHT_CORRELATED: boolean;
  53723. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53724. SPHERICAL_HARMONICS: boolean;
  53725. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53726. /** @hidden */
  53727. _areMiscDirty: boolean;
  53728. }
  53729. /**
  53730. * Define the code related to the BRDF parameters of the pbr material.
  53731. */
  53732. export class PBRBRDFConfiguration {
  53733. /**
  53734. * Default value used for the energy conservation.
  53735. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53736. */
  53737. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53738. /**
  53739. * Default value used for the Smith Visibility Height Correlated mode.
  53740. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53741. */
  53742. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53743. /**
  53744. * Default value used for the IBL diffuse part.
  53745. * This can help switching back to the polynomials mode globally which is a tiny bit
  53746. * less GPU intensive at the drawback of a lower quality.
  53747. */
  53748. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53749. /**
  53750. * Default value used for activating energy conservation for the specular workflow.
  53751. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53752. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53753. */
  53754. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53755. private _useEnergyConservation;
  53756. /**
  53757. * Defines if the material uses energy conservation.
  53758. */
  53759. useEnergyConservation: boolean;
  53760. private _useSmithVisibilityHeightCorrelated;
  53761. /**
  53762. * LEGACY Mode set to false
  53763. * Defines if the material uses height smith correlated visibility term.
  53764. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53765. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53766. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53767. * Not relying on height correlated will also disable energy conservation.
  53768. */
  53769. useSmithVisibilityHeightCorrelated: boolean;
  53770. private _useSphericalHarmonics;
  53771. /**
  53772. * LEGACY Mode set to false
  53773. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53774. * diffuse part of the IBL.
  53775. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53776. * to the ground truth.
  53777. */
  53778. useSphericalHarmonics: boolean;
  53779. private _useSpecularGlossinessInputEnergyConservation;
  53780. /**
  53781. * Defines if the material uses energy conservation, when the specular workflow is active.
  53782. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53783. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53784. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53785. */
  53786. useSpecularGlossinessInputEnergyConservation: boolean;
  53787. /** @hidden */
  53788. private _internalMarkAllSubMeshesAsMiscDirty;
  53789. /** @hidden */
  53790. _markAllSubMeshesAsMiscDirty(): void;
  53791. /**
  53792. * Instantiate a new istance of clear coat configuration.
  53793. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53794. */
  53795. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53796. /**
  53797. * Checks to see if a texture is used in the material.
  53798. * @param defines the list of "defines" to update.
  53799. */
  53800. prepareDefines(defines: IMaterialBRDFDefines): void;
  53801. /**
  53802. * Get the current class name of the texture useful for serialization or dynamic coding.
  53803. * @returns "PBRClearCoatConfiguration"
  53804. */
  53805. getClassName(): string;
  53806. /**
  53807. * Makes a duplicate of the current configuration into another one.
  53808. * @param brdfConfiguration define the config where to copy the info
  53809. */
  53810. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53811. /**
  53812. * Serializes this BRDF configuration.
  53813. * @returns - An object with the serialized config.
  53814. */
  53815. serialize(): any;
  53816. /**
  53817. * Parses a anisotropy Configuration from a serialized object.
  53818. * @param source - Serialized object.
  53819. * @param scene Defines the scene we are parsing for
  53820. * @param rootUrl Defines the rootUrl to load from
  53821. */
  53822. parse(source: any, scene: Scene, rootUrl: string): void;
  53823. }
  53824. }
  53825. declare module BABYLON {
  53826. /**
  53827. * @hidden
  53828. */
  53829. export interface IMaterialSheenDefines {
  53830. SHEEN: boolean;
  53831. SHEEN_TEXTURE: boolean;
  53832. SHEEN_TEXTUREDIRECTUV: number;
  53833. SHEEN_LINKWITHALBEDO: boolean;
  53834. SHEEN_ROUGHNESS: boolean;
  53835. SHEEN_ALBEDOSCALING: boolean;
  53836. /** @hidden */
  53837. _areTexturesDirty: boolean;
  53838. }
  53839. /**
  53840. * Define the code related to the Sheen parameters of the pbr material.
  53841. */
  53842. export class PBRSheenConfiguration {
  53843. private _isEnabled;
  53844. /**
  53845. * Defines if the material uses sheen.
  53846. */
  53847. isEnabled: boolean;
  53848. private _linkSheenWithAlbedo;
  53849. /**
  53850. * Defines if the sheen is linked to the sheen color.
  53851. */
  53852. linkSheenWithAlbedo: boolean;
  53853. /**
  53854. * Defines the sheen intensity.
  53855. */
  53856. intensity: number;
  53857. /**
  53858. * Defines the sheen color.
  53859. */
  53860. color: Color3;
  53861. private _texture;
  53862. /**
  53863. * Stores the sheen tint values in a texture.
  53864. * rgb is tint
  53865. * a is a intensity
  53866. */
  53867. texture: Nullable<BaseTexture>;
  53868. private _roughness;
  53869. /**
  53870. * Defines the sheen roughness.
  53871. * It is not taken into account if linkSheenWithAlbedo is true.
  53872. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53873. */
  53874. roughness: Nullable<number>;
  53875. private _albedoScaling;
  53876. /**
  53877. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53878. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53879. * making it easier to setup and tweak the effect
  53880. */
  53881. albedoScaling: boolean;
  53882. /** @hidden */
  53883. private _internalMarkAllSubMeshesAsTexturesDirty;
  53884. /** @hidden */
  53885. _markAllSubMeshesAsTexturesDirty(): void;
  53886. /**
  53887. * Instantiate a new istance of clear coat configuration.
  53888. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53889. */
  53890. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53891. /**
  53892. * Specifies that the submesh is ready to be used.
  53893. * @param defines the list of "defines" to update.
  53894. * @param scene defines the scene the material belongs to.
  53895. * @returns - boolean indicating that the submesh is ready or not.
  53896. */
  53897. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53898. /**
  53899. * Checks to see if a texture is used in the material.
  53900. * @param defines the list of "defines" to update.
  53901. * @param scene defines the scene the material belongs to.
  53902. */
  53903. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53904. /**
  53905. * Binds the material data.
  53906. * @param uniformBuffer defines the Uniform buffer to fill in.
  53907. * @param scene defines the scene the material belongs to.
  53908. * @param isFrozen defines wether the material is frozen or not.
  53909. */
  53910. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53911. /**
  53912. * Checks to see if a texture is used in the material.
  53913. * @param texture - Base texture to use.
  53914. * @returns - Boolean specifying if a texture is used in the material.
  53915. */
  53916. hasTexture(texture: BaseTexture): boolean;
  53917. /**
  53918. * Returns an array of the actively used textures.
  53919. * @param activeTextures Array of BaseTextures
  53920. */
  53921. getActiveTextures(activeTextures: BaseTexture[]): void;
  53922. /**
  53923. * Returns the animatable textures.
  53924. * @param animatables Array of animatable textures.
  53925. */
  53926. getAnimatables(animatables: IAnimatable[]): void;
  53927. /**
  53928. * Disposes the resources of the material.
  53929. * @param forceDisposeTextures - Forces the disposal of all textures.
  53930. */
  53931. dispose(forceDisposeTextures?: boolean): void;
  53932. /**
  53933. * Get the current class name of the texture useful for serialization or dynamic coding.
  53934. * @returns "PBRSheenConfiguration"
  53935. */
  53936. getClassName(): string;
  53937. /**
  53938. * Add fallbacks to the effect fallbacks list.
  53939. * @param defines defines the Base texture to use.
  53940. * @param fallbacks defines the current fallback list.
  53941. * @param currentRank defines the current fallback rank.
  53942. * @returns the new fallback rank.
  53943. */
  53944. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53945. /**
  53946. * Add the required uniforms to the current list.
  53947. * @param uniforms defines the current uniform list.
  53948. */
  53949. static AddUniforms(uniforms: string[]): void;
  53950. /**
  53951. * Add the required uniforms to the current buffer.
  53952. * @param uniformBuffer defines the current uniform buffer.
  53953. */
  53954. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53955. /**
  53956. * Add the required samplers to the current list.
  53957. * @param samplers defines the current sampler list.
  53958. */
  53959. static AddSamplers(samplers: string[]): void;
  53960. /**
  53961. * Makes a duplicate of the current configuration into another one.
  53962. * @param sheenConfiguration define the config where to copy the info
  53963. */
  53964. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53965. /**
  53966. * Serializes this BRDF configuration.
  53967. * @returns - An object with the serialized config.
  53968. */
  53969. serialize(): any;
  53970. /**
  53971. * Parses a anisotropy Configuration from a serialized object.
  53972. * @param source - Serialized object.
  53973. * @param scene Defines the scene we are parsing for
  53974. * @param rootUrl Defines the rootUrl to load from
  53975. */
  53976. parse(source: any, scene: Scene, rootUrl: string): void;
  53977. }
  53978. }
  53979. declare module BABYLON {
  53980. /**
  53981. * @hidden
  53982. */
  53983. export interface IMaterialSubSurfaceDefines {
  53984. SUBSURFACE: boolean;
  53985. SS_REFRACTION: boolean;
  53986. SS_TRANSLUCENCY: boolean;
  53987. SS_SCATERRING: boolean;
  53988. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53989. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53990. SS_REFRACTIONMAP_3D: boolean;
  53991. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53992. SS_LODINREFRACTIONALPHA: boolean;
  53993. SS_GAMMAREFRACTION: boolean;
  53994. SS_RGBDREFRACTION: boolean;
  53995. SS_LINEARSPECULARREFRACTION: boolean;
  53996. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53997. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53998. /** @hidden */
  53999. _areTexturesDirty: boolean;
  54000. }
  54001. /**
  54002. * Define the code related to the sub surface parameters of the pbr material.
  54003. */
  54004. export class PBRSubSurfaceConfiguration {
  54005. private _isRefractionEnabled;
  54006. /**
  54007. * Defines if the refraction is enabled in the material.
  54008. */
  54009. isRefractionEnabled: boolean;
  54010. private _isTranslucencyEnabled;
  54011. /**
  54012. * Defines if the translucency is enabled in the material.
  54013. */
  54014. isTranslucencyEnabled: boolean;
  54015. private _isScatteringEnabled;
  54016. /**
  54017. * Defines the refraction intensity of the material.
  54018. * The refraction when enabled replaces the Diffuse part of the material.
  54019. * The intensity helps transitionning between diffuse and refraction.
  54020. */
  54021. refractionIntensity: number;
  54022. /**
  54023. * Defines the translucency intensity of the material.
  54024. * When translucency has been enabled, this defines how much of the "translucency"
  54025. * is addded to the diffuse part of the material.
  54026. */
  54027. translucencyIntensity: number;
  54028. /**
  54029. * Defines the scattering intensity of the material.
  54030. * When scattering has been enabled, this defines how much of the "scattered light"
  54031. * is addded to the diffuse part of the material.
  54032. */
  54033. scatteringIntensity: number;
  54034. private _thicknessTexture;
  54035. /**
  54036. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54037. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54038. * 0 would mean minimumThickness
  54039. * 1 would mean maximumThickness
  54040. * The other channels might be use as a mask to vary the different effects intensity.
  54041. */
  54042. thicknessTexture: Nullable<BaseTexture>;
  54043. private _refractionTexture;
  54044. /**
  54045. * Defines the texture to use for refraction.
  54046. */
  54047. refractionTexture: Nullable<BaseTexture>;
  54048. private _indexOfRefraction;
  54049. /**
  54050. * Index of refraction of the material base layer.
  54051. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54052. *
  54053. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54054. *
  54055. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54056. */
  54057. indexOfRefraction: number;
  54058. private _invertRefractionY;
  54059. /**
  54060. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54061. */
  54062. invertRefractionY: boolean;
  54063. private _linkRefractionWithTransparency;
  54064. /**
  54065. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54066. * Materials half opaque for instance using refraction could benefit from this control.
  54067. */
  54068. linkRefractionWithTransparency: boolean;
  54069. /**
  54070. * Defines the minimum thickness stored in the thickness map.
  54071. * If no thickness map is defined, this value will be used to simulate thickness.
  54072. */
  54073. minimumThickness: number;
  54074. /**
  54075. * Defines the maximum thickness stored in the thickness map.
  54076. */
  54077. maximumThickness: number;
  54078. /**
  54079. * Defines the volume tint of the material.
  54080. * This is used for both translucency and scattering.
  54081. */
  54082. tintColor: Color3;
  54083. /**
  54084. * Defines the distance at which the tint color should be found in the media.
  54085. * This is used for refraction only.
  54086. */
  54087. tintColorAtDistance: number;
  54088. /**
  54089. * Defines how far each channel transmit through the media.
  54090. * It is defined as a color to simplify it selection.
  54091. */
  54092. diffusionDistance: Color3;
  54093. private _useMaskFromThicknessTexture;
  54094. /**
  54095. * Stores the intensity of the different subsurface effects in the thickness texture.
  54096. * * the green channel is the translucency intensity.
  54097. * * the blue channel is the scattering intensity.
  54098. * * the alpha channel is the refraction intensity.
  54099. */
  54100. useMaskFromThicknessTexture: boolean;
  54101. /** @hidden */
  54102. private _internalMarkAllSubMeshesAsTexturesDirty;
  54103. /** @hidden */
  54104. _markAllSubMeshesAsTexturesDirty(): void;
  54105. /**
  54106. * Instantiate a new istance of sub surface configuration.
  54107. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54108. */
  54109. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54110. /**
  54111. * Gets wehter the submesh is ready to be used or not.
  54112. * @param defines the list of "defines" to update.
  54113. * @param scene defines the scene the material belongs to.
  54114. * @returns - boolean indicating that the submesh is ready or not.
  54115. */
  54116. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54117. /**
  54118. * Checks to see if a texture is used in the material.
  54119. * @param defines the list of "defines" to update.
  54120. * @param scene defines the scene to the material belongs to.
  54121. */
  54122. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54123. /**
  54124. * Binds the material data.
  54125. * @param uniformBuffer defines the Uniform buffer to fill in.
  54126. * @param scene defines the scene the material belongs to.
  54127. * @param engine defines the engine the material belongs to.
  54128. * @param isFrozen defines whether the material is frozen or not.
  54129. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54130. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54131. */
  54132. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54133. /**
  54134. * Unbinds the material from the mesh.
  54135. * @param activeEffect defines the effect that should be unbound from.
  54136. * @returns true if unbound, otherwise false
  54137. */
  54138. unbind(activeEffect: Effect): boolean;
  54139. /**
  54140. * Returns the texture used for refraction or null if none is used.
  54141. * @param scene defines the scene the material belongs to.
  54142. * @returns - Refraction texture if present. If no refraction texture and refraction
  54143. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54144. */
  54145. private _getRefractionTexture;
  54146. /**
  54147. * Returns true if alpha blending should be disabled.
  54148. */
  54149. get disableAlphaBlending(): boolean;
  54150. /**
  54151. * Fills the list of render target textures.
  54152. * @param renderTargets the list of render targets to update
  54153. */
  54154. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54155. /**
  54156. * Checks to see if a texture is used in the material.
  54157. * @param texture - Base texture to use.
  54158. * @returns - Boolean specifying if a texture is used in the material.
  54159. */
  54160. hasTexture(texture: BaseTexture): boolean;
  54161. /**
  54162. * Gets a boolean indicating that current material needs to register RTT
  54163. * @returns true if this uses a render target otherwise false.
  54164. */
  54165. hasRenderTargetTextures(): boolean;
  54166. /**
  54167. * Returns an array of the actively used textures.
  54168. * @param activeTextures Array of BaseTextures
  54169. */
  54170. getActiveTextures(activeTextures: BaseTexture[]): void;
  54171. /**
  54172. * Returns the animatable textures.
  54173. * @param animatables Array of animatable textures.
  54174. */
  54175. getAnimatables(animatables: IAnimatable[]): void;
  54176. /**
  54177. * Disposes the resources of the material.
  54178. * @param forceDisposeTextures - Forces the disposal of all textures.
  54179. */
  54180. dispose(forceDisposeTextures?: boolean): void;
  54181. /**
  54182. * Get the current class name of the texture useful for serialization or dynamic coding.
  54183. * @returns "PBRSubSurfaceConfiguration"
  54184. */
  54185. getClassName(): string;
  54186. /**
  54187. * Add fallbacks to the effect fallbacks list.
  54188. * @param defines defines the Base texture to use.
  54189. * @param fallbacks defines the current fallback list.
  54190. * @param currentRank defines the current fallback rank.
  54191. * @returns the new fallback rank.
  54192. */
  54193. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54194. /**
  54195. * Add the required uniforms to the current list.
  54196. * @param uniforms defines the current uniform list.
  54197. */
  54198. static AddUniforms(uniforms: string[]): void;
  54199. /**
  54200. * Add the required samplers to the current list.
  54201. * @param samplers defines the current sampler list.
  54202. */
  54203. static AddSamplers(samplers: string[]): void;
  54204. /**
  54205. * Add the required uniforms to the current buffer.
  54206. * @param uniformBuffer defines the current uniform buffer.
  54207. */
  54208. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54209. /**
  54210. * Makes a duplicate of the current configuration into another one.
  54211. * @param configuration define the config where to copy the info
  54212. */
  54213. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54214. /**
  54215. * Serializes this Sub Surface configuration.
  54216. * @returns - An object with the serialized config.
  54217. */
  54218. serialize(): any;
  54219. /**
  54220. * Parses a anisotropy Configuration from a serialized object.
  54221. * @param source - Serialized object.
  54222. * @param scene Defines the scene we are parsing for
  54223. * @param rootUrl Defines the rootUrl to load from
  54224. */
  54225. parse(source: any, scene: Scene, rootUrl: string): void;
  54226. }
  54227. }
  54228. declare module BABYLON {
  54229. /** @hidden */
  54230. export var pbrFragmentDeclaration: {
  54231. name: string;
  54232. shader: string;
  54233. };
  54234. }
  54235. declare module BABYLON {
  54236. /** @hidden */
  54237. export var pbrUboDeclaration: {
  54238. name: string;
  54239. shader: string;
  54240. };
  54241. }
  54242. declare module BABYLON {
  54243. /** @hidden */
  54244. export var pbrFragmentExtraDeclaration: {
  54245. name: string;
  54246. shader: string;
  54247. };
  54248. }
  54249. declare module BABYLON {
  54250. /** @hidden */
  54251. export var pbrFragmentSamplersDeclaration: {
  54252. name: string;
  54253. shader: string;
  54254. };
  54255. }
  54256. declare module BABYLON {
  54257. /** @hidden */
  54258. export var importanceSampling: {
  54259. name: string;
  54260. shader: string;
  54261. };
  54262. }
  54263. declare module BABYLON {
  54264. /** @hidden */
  54265. export var pbrHelperFunctions: {
  54266. name: string;
  54267. shader: string;
  54268. };
  54269. }
  54270. declare module BABYLON {
  54271. /** @hidden */
  54272. export var harmonicsFunctions: {
  54273. name: string;
  54274. shader: string;
  54275. };
  54276. }
  54277. declare module BABYLON {
  54278. /** @hidden */
  54279. export var pbrDirectLightingSetupFunctions: {
  54280. name: string;
  54281. shader: string;
  54282. };
  54283. }
  54284. declare module BABYLON {
  54285. /** @hidden */
  54286. export var pbrDirectLightingFalloffFunctions: {
  54287. name: string;
  54288. shader: string;
  54289. };
  54290. }
  54291. declare module BABYLON {
  54292. /** @hidden */
  54293. export var pbrBRDFFunctions: {
  54294. name: string;
  54295. shader: string;
  54296. };
  54297. }
  54298. declare module BABYLON {
  54299. /** @hidden */
  54300. export var hdrFilteringFunctions: {
  54301. name: string;
  54302. shader: string;
  54303. };
  54304. }
  54305. declare module BABYLON {
  54306. /** @hidden */
  54307. export var pbrDirectLightingFunctions: {
  54308. name: string;
  54309. shader: string;
  54310. };
  54311. }
  54312. declare module BABYLON {
  54313. /** @hidden */
  54314. export var pbrIBLFunctions: {
  54315. name: string;
  54316. shader: string;
  54317. };
  54318. }
  54319. declare module BABYLON {
  54320. /** @hidden */
  54321. export var pbrBlockAlbedoOpacity: {
  54322. name: string;
  54323. shader: string;
  54324. };
  54325. }
  54326. declare module BABYLON {
  54327. /** @hidden */
  54328. export var pbrBlockReflectivity: {
  54329. name: string;
  54330. shader: string;
  54331. };
  54332. }
  54333. declare module BABYLON {
  54334. /** @hidden */
  54335. export var pbrBlockAmbientOcclusion: {
  54336. name: string;
  54337. shader: string;
  54338. };
  54339. }
  54340. declare module BABYLON {
  54341. /** @hidden */
  54342. export var pbrBlockAlphaFresnel: {
  54343. name: string;
  54344. shader: string;
  54345. };
  54346. }
  54347. declare module BABYLON {
  54348. /** @hidden */
  54349. export var pbrBlockAnisotropic: {
  54350. name: string;
  54351. shader: string;
  54352. };
  54353. }
  54354. declare module BABYLON {
  54355. /** @hidden */
  54356. export var pbrBlockReflection: {
  54357. name: string;
  54358. shader: string;
  54359. };
  54360. }
  54361. declare module BABYLON {
  54362. /** @hidden */
  54363. export var pbrBlockSheen: {
  54364. name: string;
  54365. shader: string;
  54366. };
  54367. }
  54368. declare module BABYLON {
  54369. /** @hidden */
  54370. export var pbrBlockClearcoat: {
  54371. name: string;
  54372. shader: string;
  54373. };
  54374. }
  54375. declare module BABYLON {
  54376. /** @hidden */
  54377. export var pbrBlockSubSurface: {
  54378. name: string;
  54379. shader: string;
  54380. };
  54381. }
  54382. declare module BABYLON {
  54383. /** @hidden */
  54384. export var pbrBlockNormalGeometric: {
  54385. name: string;
  54386. shader: string;
  54387. };
  54388. }
  54389. declare module BABYLON {
  54390. /** @hidden */
  54391. export var pbrBlockNormalFinal: {
  54392. name: string;
  54393. shader: string;
  54394. };
  54395. }
  54396. declare module BABYLON {
  54397. /** @hidden */
  54398. export var pbrBlockGeometryInfo: {
  54399. name: string;
  54400. shader: string;
  54401. };
  54402. }
  54403. declare module BABYLON {
  54404. /** @hidden */
  54405. export var pbrBlockReflectance0: {
  54406. name: string;
  54407. shader: string;
  54408. };
  54409. }
  54410. declare module BABYLON {
  54411. /** @hidden */
  54412. export var pbrBlockReflectance: {
  54413. name: string;
  54414. shader: string;
  54415. };
  54416. }
  54417. declare module BABYLON {
  54418. /** @hidden */
  54419. export var pbrBlockDirectLighting: {
  54420. name: string;
  54421. shader: string;
  54422. };
  54423. }
  54424. declare module BABYLON {
  54425. /** @hidden */
  54426. export var pbrBlockFinalLitComponents: {
  54427. name: string;
  54428. shader: string;
  54429. };
  54430. }
  54431. declare module BABYLON {
  54432. /** @hidden */
  54433. export var pbrBlockFinalUnlitComponents: {
  54434. name: string;
  54435. shader: string;
  54436. };
  54437. }
  54438. declare module BABYLON {
  54439. /** @hidden */
  54440. export var pbrBlockFinalColorComposition: {
  54441. name: string;
  54442. shader: string;
  54443. };
  54444. }
  54445. declare module BABYLON {
  54446. /** @hidden */
  54447. export var pbrBlockImageProcessing: {
  54448. name: string;
  54449. shader: string;
  54450. };
  54451. }
  54452. declare module BABYLON {
  54453. /** @hidden */
  54454. export var pbrDebug: {
  54455. name: string;
  54456. shader: string;
  54457. };
  54458. }
  54459. declare module BABYLON {
  54460. /** @hidden */
  54461. export var pbrPixelShader: {
  54462. name: string;
  54463. shader: string;
  54464. };
  54465. }
  54466. declare module BABYLON {
  54467. /** @hidden */
  54468. export var pbrVertexDeclaration: {
  54469. name: string;
  54470. shader: string;
  54471. };
  54472. }
  54473. declare module BABYLON {
  54474. /** @hidden */
  54475. export var pbrVertexShader: {
  54476. name: string;
  54477. shader: string;
  54478. };
  54479. }
  54480. declare module BABYLON {
  54481. /**
  54482. * Manages the defines for the PBR Material.
  54483. * @hidden
  54484. */
  54485. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  54486. PBR: boolean;
  54487. NUM_SAMPLES: string;
  54488. REALTIME_FILTERING: boolean;
  54489. MAINUV1: boolean;
  54490. MAINUV2: boolean;
  54491. UV1: boolean;
  54492. UV2: boolean;
  54493. ALBEDO: boolean;
  54494. GAMMAALBEDO: boolean;
  54495. ALBEDODIRECTUV: number;
  54496. VERTEXCOLOR: boolean;
  54497. AMBIENT: boolean;
  54498. AMBIENTDIRECTUV: number;
  54499. AMBIENTINGRAYSCALE: boolean;
  54500. OPACITY: boolean;
  54501. VERTEXALPHA: boolean;
  54502. OPACITYDIRECTUV: number;
  54503. OPACITYRGB: boolean;
  54504. ALPHATEST: boolean;
  54505. DEPTHPREPASS: boolean;
  54506. ALPHABLEND: boolean;
  54507. ALPHAFROMALBEDO: boolean;
  54508. ALPHATESTVALUE: string;
  54509. SPECULAROVERALPHA: boolean;
  54510. RADIANCEOVERALPHA: boolean;
  54511. ALPHAFRESNEL: boolean;
  54512. LINEARALPHAFRESNEL: boolean;
  54513. PREMULTIPLYALPHA: boolean;
  54514. EMISSIVE: boolean;
  54515. EMISSIVEDIRECTUV: number;
  54516. REFLECTIVITY: boolean;
  54517. REFLECTIVITYDIRECTUV: number;
  54518. SPECULARTERM: boolean;
  54519. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54520. MICROSURFACEAUTOMATIC: boolean;
  54521. LODBASEDMICROSFURACE: boolean;
  54522. MICROSURFACEMAP: boolean;
  54523. MICROSURFACEMAPDIRECTUV: number;
  54524. METALLICWORKFLOW: boolean;
  54525. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54526. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54527. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54528. AOSTOREINMETALMAPRED: boolean;
  54529. METALLIC_REFLECTANCE: boolean;
  54530. METALLIC_REFLECTANCEDIRECTUV: number;
  54531. ENVIRONMENTBRDF: boolean;
  54532. ENVIRONMENTBRDF_RGBD: boolean;
  54533. NORMAL: boolean;
  54534. TANGENT: boolean;
  54535. BUMP: boolean;
  54536. BUMPDIRECTUV: number;
  54537. OBJECTSPACE_NORMALMAP: boolean;
  54538. PARALLAX: boolean;
  54539. PARALLAXOCCLUSION: boolean;
  54540. NORMALXYSCALE: boolean;
  54541. LIGHTMAP: boolean;
  54542. LIGHTMAPDIRECTUV: number;
  54543. USELIGHTMAPASSHADOWMAP: boolean;
  54544. GAMMALIGHTMAP: boolean;
  54545. RGBDLIGHTMAP: boolean;
  54546. REFLECTION: boolean;
  54547. REFLECTIONMAP_3D: boolean;
  54548. REFLECTIONMAP_SPHERICAL: boolean;
  54549. REFLECTIONMAP_PLANAR: boolean;
  54550. REFLECTIONMAP_CUBIC: boolean;
  54551. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54552. REFLECTIONMAP_PROJECTION: boolean;
  54553. REFLECTIONMAP_SKYBOX: boolean;
  54554. REFLECTIONMAP_EXPLICIT: boolean;
  54555. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54556. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54557. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54558. INVERTCUBICMAP: boolean;
  54559. USESPHERICALFROMREFLECTIONMAP: boolean;
  54560. USEIRRADIANCEMAP: boolean;
  54561. SPHERICAL_HARMONICS: boolean;
  54562. USESPHERICALINVERTEX: boolean;
  54563. REFLECTIONMAP_OPPOSITEZ: boolean;
  54564. LODINREFLECTIONALPHA: boolean;
  54565. GAMMAREFLECTION: boolean;
  54566. RGBDREFLECTION: boolean;
  54567. LINEARSPECULARREFLECTION: boolean;
  54568. RADIANCEOCCLUSION: boolean;
  54569. HORIZONOCCLUSION: boolean;
  54570. INSTANCES: boolean;
  54571. NUM_BONE_INFLUENCERS: number;
  54572. BonesPerMesh: number;
  54573. BONETEXTURE: boolean;
  54574. NONUNIFORMSCALING: boolean;
  54575. MORPHTARGETS: boolean;
  54576. MORPHTARGETS_NORMAL: boolean;
  54577. MORPHTARGETS_TANGENT: boolean;
  54578. MORPHTARGETS_UV: boolean;
  54579. NUM_MORPH_INFLUENCERS: number;
  54580. IMAGEPROCESSING: boolean;
  54581. VIGNETTE: boolean;
  54582. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54583. VIGNETTEBLENDMODEOPAQUE: boolean;
  54584. TONEMAPPING: boolean;
  54585. TONEMAPPING_ACES: boolean;
  54586. CONTRAST: boolean;
  54587. COLORCURVES: boolean;
  54588. COLORGRADING: boolean;
  54589. COLORGRADING3D: boolean;
  54590. SAMPLER3DGREENDEPTH: boolean;
  54591. SAMPLER3DBGRMAP: boolean;
  54592. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54593. EXPOSURE: boolean;
  54594. MULTIVIEW: boolean;
  54595. USEPHYSICALLIGHTFALLOFF: boolean;
  54596. USEGLTFLIGHTFALLOFF: boolean;
  54597. TWOSIDEDLIGHTING: boolean;
  54598. SHADOWFLOAT: boolean;
  54599. CLIPPLANE: boolean;
  54600. CLIPPLANE2: boolean;
  54601. CLIPPLANE3: boolean;
  54602. CLIPPLANE4: boolean;
  54603. CLIPPLANE5: boolean;
  54604. CLIPPLANE6: boolean;
  54605. POINTSIZE: boolean;
  54606. FOG: boolean;
  54607. LOGARITHMICDEPTH: boolean;
  54608. FORCENORMALFORWARD: boolean;
  54609. SPECULARAA: boolean;
  54610. CLEARCOAT: boolean;
  54611. CLEARCOAT_DEFAULTIOR: boolean;
  54612. CLEARCOAT_TEXTURE: boolean;
  54613. CLEARCOAT_TEXTUREDIRECTUV: number;
  54614. CLEARCOAT_BUMP: boolean;
  54615. CLEARCOAT_BUMPDIRECTUV: number;
  54616. CLEARCOAT_TINT: boolean;
  54617. CLEARCOAT_TINT_TEXTURE: boolean;
  54618. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54619. ANISOTROPIC: boolean;
  54620. ANISOTROPIC_TEXTURE: boolean;
  54621. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54622. BRDF_V_HEIGHT_CORRELATED: boolean;
  54623. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54624. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54625. SHEEN: boolean;
  54626. SHEEN_TEXTURE: boolean;
  54627. SHEEN_TEXTUREDIRECTUV: number;
  54628. SHEEN_LINKWITHALBEDO: boolean;
  54629. SHEEN_ROUGHNESS: boolean;
  54630. SHEEN_ALBEDOSCALING: boolean;
  54631. SUBSURFACE: boolean;
  54632. SS_REFRACTION: boolean;
  54633. SS_TRANSLUCENCY: boolean;
  54634. SS_SCATERRING: boolean;
  54635. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54636. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54637. SS_REFRACTIONMAP_3D: boolean;
  54638. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54639. SS_LODINREFRACTIONALPHA: boolean;
  54640. SS_GAMMAREFRACTION: boolean;
  54641. SS_RGBDREFRACTION: boolean;
  54642. SS_LINEARSPECULARREFRACTION: boolean;
  54643. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54644. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54645. UNLIT: boolean;
  54646. DEBUGMODE: number;
  54647. /**
  54648. * Initializes the PBR Material defines.
  54649. */
  54650. constructor();
  54651. /**
  54652. * Resets the PBR Material defines.
  54653. */
  54654. reset(): void;
  54655. }
  54656. /**
  54657. * The Physically based material base class of BJS.
  54658. *
  54659. * This offers the main features of a standard PBR material.
  54660. * For more information, please refer to the documentation :
  54661. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54662. */
  54663. export abstract class PBRBaseMaterial extends PushMaterial {
  54664. /**
  54665. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54666. */
  54667. static readonly PBRMATERIAL_OPAQUE: number;
  54668. /**
  54669. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54670. */
  54671. static readonly PBRMATERIAL_ALPHATEST: number;
  54672. /**
  54673. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54674. */
  54675. static readonly PBRMATERIAL_ALPHABLEND: number;
  54676. /**
  54677. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54678. * They are also discarded below the alpha cutoff threshold to improve performances.
  54679. */
  54680. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54681. /**
  54682. * Defines the default value of how much AO map is occluding the analytical lights
  54683. * (point spot...).
  54684. */
  54685. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54686. /**
  54687. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54688. */
  54689. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54690. /**
  54691. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54692. * to enhance interoperability with other engines.
  54693. */
  54694. static readonly LIGHTFALLOFF_GLTF: number;
  54695. /**
  54696. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54697. * to enhance interoperability with other materials.
  54698. */
  54699. static readonly LIGHTFALLOFF_STANDARD: number;
  54700. /**
  54701. * Intensity of the direct lights e.g. the four lights available in your scene.
  54702. * This impacts both the direct diffuse and specular highlights.
  54703. */
  54704. protected _directIntensity: number;
  54705. /**
  54706. * Intensity of the emissive part of the material.
  54707. * This helps controlling the emissive effect without modifying the emissive color.
  54708. */
  54709. protected _emissiveIntensity: number;
  54710. /**
  54711. * Intensity of the environment e.g. how much the environment will light the object
  54712. * either through harmonics for rough material or through the refelction for shiny ones.
  54713. */
  54714. protected _environmentIntensity: number;
  54715. /**
  54716. * This is a special control allowing the reduction of the specular highlights coming from the
  54717. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54718. */
  54719. protected _specularIntensity: number;
  54720. /**
  54721. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54722. */
  54723. private _lightingInfos;
  54724. /**
  54725. * Debug Control allowing disabling the bump map on this material.
  54726. */
  54727. protected _disableBumpMap: boolean;
  54728. /**
  54729. * AKA Diffuse Texture in standard nomenclature.
  54730. */
  54731. protected _albedoTexture: Nullable<BaseTexture>;
  54732. /**
  54733. * AKA Occlusion Texture in other nomenclature.
  54734. */
  54735. protected _ambientTexture: Nullable<BaseTexture>;
  54736. /**
  54737. * AKA Occlusion Texture Intensity in other nomenclature.
  54738. */
  54739. protected _ambientTextureStrength: number;
  54740. /**
  54741. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54742. * 1 means it completely occludes it
  54743. * 0 mean it has no impact
  54744. */
  54745. protected _ambientTextureImpactOnAnalyticalLights: number;
  54746. /**
  54747. * Stores the alpha values in a texture.
  54748. */
  54749. protected _opacityTexture: Nullable<BaseTexture>;
  54750. /**
  54751. * Stores the reflection values in a texture.
  54752. */
  54753. protected _reflectionTexture: Nullable<BaseTexture>;
  54754. /**
  54755. * Stores the emissive values in a texture.
  54756. */
  54757. protected _emissiveTexture: Nullable<BaseTexture>;
  54758. /**
  54759. * AKA Specular texture in other nomenclature.
  54760. */
  54761. protected _reflectivityTexture: Nullable<BaseTexture>;
  54762. /**
  54763. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54764. */
  54765. protected _metallicTexture: Nullable<BaseTexture>;
  54766. /**
  54767. * Specifies the metallic scalar of the metallic/roughness workflow.
  54768. * Can also be used to scale the metalness values of the metallic texture.
  54769. */
  54770. protected _metallic: Nullable<number>;
  54771. /**
  54772. * Specifies the roughness scalar of the metallic/roughness workflow.
  54773. * Can also be used to scale the roughness values of the metallic texture.
  54774. */
  54775. protected _roughness: Nullable<number>;
  54776. /**
  54777. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  54778. * By default the indexOfrefraction is used to compute F0;
  54779. *
  54780. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  54781. *
  54782. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  54783. * F90 = metallicReflectanceColor;
  54784. */
  54785. protected _metallicF0Factor: number;
  54786. /**
  54787. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  54788. * By default the F90 is always 1;
  54789. *
  54790. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  54791. *
  54792. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  54793. * F90 = metallicReflectanceColor;
  54794. */
  54795. protected _metallicReflectanceColor: Color3;
  54796. /**
  54797. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  54798. * This is multiply against the scalar values defined in the material.
  54799. */
  54800. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  54801. /**
  54802. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54803. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54804. */
  54805. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54806. /**
  54807. * Stores surface normal data used to displace a mesh in a texture.
  54808. */
  54809. protected _bumpTexture: Nullable<BaseTexture>;
  54810. /**
  54811. * Stores the pre-calculated light information of a mesh in a texture.
  54812. */
  54813. protected _lightmapTexture: Nullable<BaseTexture>;
  54814. /**
  54815. * The color of a material in ambient lighting.
  54816. */
  54817. protected _ambientColor: Color3;
  54818. /**
  54819. * AKA Diffuse Color in other nomenclature.
  54820. */
  54821. protected _albedoColor: Color3;
  54822. /**
  54823. * AKA Specular Color in other nomenclature.
  54824. */
  54825. protected _reflectivityColor: Color3;
  54826. /**
  54827. * The color applied when light is reflected from a material.
  54828. */
  54829. protected _reflectionColor: Color3;
  54830. /**
  54831. * The color applied when light is emitted from a material.
  54832. */
  54833. protected _emissiveColor: Color3;
  54834. /**
  54835. * AKA Glossiness in other nomenclature.
  54836. */
  54837. protected _microSurface: number;
  54838. /**
  54839. * Specifies that the material will use the light map as a show map.
  54840. */
  54841. protected _useLightmapAsShadowmap: boolean;
  54842. /**
  54843. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54844. * makes the reflect vector face the model (under horizon).
  54845. */
  54846. protected _useHorizonOcclusion: boolean;
  54847. /**
  54848. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54849. * too much the area relying on ambient texture to define their ambient occlusion.
  54850. */
  54851. protected _useRadianceOcclusion: boolean;
  54852. /**
  54853. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54854. */
  54855. protected _useAlphaFromAlbedoTexture: boolean;
  54856. /**
  54857. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54858. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54859. */
  54860. protected _useSpecularOverAlpha: boolean;
  54861. /**
  54862. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54863. */
  54864. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54865. /**
  54866. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54867. */
  54868. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54869. /**
  54870. * Specifies if the metallic texture contains the roughness information in its green channel.
  54871. */
  54872. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54873. /**
  54874. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54875. */
  54876. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54877. /**
  54878. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54879. */
  54880. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54881. /**
  54882. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54883. */
  54884. protected _useAmbientInGrayScale: boolean;
  54885. /**
  54886. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54887. * The material will try to infer what glossiness each pixel should be.
  54888. */
  54889. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54890. /**
  54891. * Defines the falloff type used in this material.
  54892. * It by default is Physical.
  54893. */
  54894. protected _lightFalloff: number;
  54895. /**
  54896. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54897. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54898. */
  54899. protected _useRadianceOverAlpha: boolean;
  54900. /**
  54901. * Allows using an object space normal map (instead of tangent space).
  54902. */
  54903. protected _useObjectSpaceNormalMap: boolean;
  54904. /**
  54905. * Allows using the bump map in parallax mode.
  54906. */
  54907. protected _useParallax: boolean;
  54908. /**
  54909. * Allows using the bump map in parallax occlusion mode.
  54910. */
  54911. protected _useParallaxOcclusion: boolean;
  54912. /**
  54913. * Controls the scale bias of the parallax mode.
  54914. */
  54915. protected _parallaxScaleBias: number;
  54916. /**
  54917. * If sets to true, disables all the lights affecting the material.
  54918. */
  54919. protected _disableLighting: boolean;
  54920. /**
  54921. * Number of Simultaneous lights allowed on the material.
  54922. */
  54923. protected _maxSimultaneousLights: number;
  54924. /**
  54925. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54926. */
  54927. protected _invertNormalMapX: boolean;
  54928. /**
  54929. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54930. */
  54931. protected _invertNormalMapY: boolean;
  54932. /**
  54933. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54934. */
  54935. protected _twoSidedLighting: boolean;
  54936. /**
  54937. * Defines the alpha limits in alpha test mode.
  54938. */
  54939. protected _alphaCutOff: number;
  54940. /**
  54941. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54942. */
  54943. protected _forceAlphaTest: boolean;
  54944. /**
  54945. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54946. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54947. */
  54948. protected _useAlphaFresnel: boolean;
  54949. /**
  54950. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54951. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54952. */
  54953. protected _useLinearAlphaFresnel: boolean;
  54954. /**
  54955. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54956. * from cos thetav and roughness:
  54957. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54958. */
  54959. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54960. /**
  54961. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54962. */
  54963. protected _forceIrradianceInFragment: boolean;
  54964. private _realTimeFiltering;
  54965. /**
  54966. * Enables realtime filtering on the texture.
  54967. */
  54968. get realTimeFiltering(): boolean;
  54969. set realTimeFiltering(b: boolean);
  54970. private _realTimeFilteringQuality;
  54971. /**
  54972. * Quality switch for realtime filtering
  54973. */
  54974. get realTimeFilteringQuality(): number;
  54975. set realTimeFilteringQuality(n: number);
  54976. /**
  54977. * Force normal to face away from face.
  54978. */
  54979. protected _forceNormalForward: boolean;
  54980. /**
  54981. * Enables specular anti aliasing in the PBR shader.
  54982. * It will both interacts on the Geometry for analytical and IBL lighting.
  54983. * It also prefilter the roughness map based on the bump values.
  54984. */
  54985. protected _enableSpecularAntiAliasing: boolean;
  54986. /**
  54987. * Default configuration related to image processing available in the PBR Material.
  54988. */
  54989. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54990. /**
  54991. * Keep track of the image processing observer to allow dispose and replace.
  54992. */
  54993. private _imageProcessingObserver;
  54994. /**
  54995. * Attaches a new image processing configuration to the PBR Material.
  54996. * @param configuration
  54997. */
  54998. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54999. /**
  55000. * Stores the available render targets.
  55001. */
  55002. private _renderTargets;
  55003. /**
  55004. * Sets the global ambient color for the material used in lighting calculations.
  55005. */
  55006. private _globalAmbientColor;
  55007. /**
  55008. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55009. */
  55010. private _useLogarithmicDepth;
  55011. /**
  55012. * If set to true, no lighting calculations will be applied.
  55013. */
  55014. private _unlit;
  55015. private _debugMode;
  55016. /**
  55017. * @hidden
  55018. * This is reserved for the inspector.
  55019. * Defines the material debug mode.
  55020. * It helps seeing only some components of the material while troubleshooting.
  55021. */
  55022. debugMode: number;
  55023. /**
  55024. * @hidden
  55025. * This is reserved for the inspector.
  55026. * Specify from where on screen the debug mode should start.
  55027. * The value goes from -1 (full screen) to 1 (not visible)
  55028. * It helps with side by side comparison against the final render
  55029. * This defaults to -1
  55030. */
  55031. private debugLimit;
  55032. /**
  55033. * @hidden
  55034. * This is reserved for the inspector.
  55035. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55036. * You can use the factor to better multiply the final value.
  55037. */
  55038. private debugFactor;
  55039. /**
  55040. * Defines the clear coat layer parameters for the material.
  55041. */
  55042. readonly clearCoat: PBRClearCoatConfiguration;
  55043. /**
  55044. * Defines the anisotropic parameters for the material.
  55045. */
  55046. readonly anisotropy: PBRAnisotropicConfiguration;
  55047. /**
  55048. * Defines the BRDF parameters for the material.
  55049. */
  55050. readonly brdf: PBRBRDFConfiguration;
  55051. /**
  55052. * Defines the Sheen parameters for the material.
  55053. */
  55054. readonly sheen: PBRSheenConfiguration;
  55055. /**
  55056. * Defines the SubSurface parameters for the material.
  55057. */
  55058. readonly subSurface: PBRSubSurfaceConfiguration;
  55059. protected _rebuildInParallel: boolean;
  55060. /**
  55061. * Instantiates a new PBRMaterial instance.
  55062. *
  55063. * @param name The material name
  55064. * @param scene The scene the material will be use in.
  55065. */
  55066. constructor(name: string, scene: Scene);
  55067. /**
  55068. * Gets a boolean indicating that current material needs to register RTT
  55069. */
  55070. get hasRenderTargetTextures(): boolean;
  55071. /**
  55072. * Gets the name of the material class.
  55073. */
  55074. getClassName(): string;
  55075. /**
  55076. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55077. */
  55078. get useLogarithmicDepth(): boolean;
  55079. /**
  55080. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55081. */
  55082. set useLogarithmicDepth(value: boolean);
  55083. /**
  55084. * Returns true if alpha blending should be disabled.
  55085. */
  55086. protected get _disableAlphaBlending(): boolean;
  55087. /**
  55088. * Specifies whether or not this material should be rendered in alpha blend mode.
  55089. */
  55090. needAlphaBlending(): boolean;
  55091. /**
  55092. * Specifies whether or not this material should be rendered in alpha test mode.
  55093. */
  55094. needAlphaTesting(): boolean;
  55095. /**
  55096. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55097. */
  55098. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55099. /**
  55100. * Gets the texture used for the alpha test.
  55101. */
  55102. getAlphaTestTexture(): Nullable<BaseTexture>;
  55103. /**
  55104. * Specifies that the submesh is ready to be used.
  55105. * @param mesh - BJS mesh.
  55106. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55107. * @param useInstances - Specifies that instances should be used.
  55108. * @returns - boolean indicating that the submesh is ready or not.
  55109. */
  55110. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55111. /**
  55112. * Specifies if the material uses metallic roughness workflow.
  55113. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55114. */
  55115. isMetallicWorkflow(): boolean;
  55116. private _prepareEffect;
  55117. private _prepareDefines;
  55118. /**
  55119. * Force shader compilation
  55120. */
  55121. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55122. /**
  55123. * Initializes the uniform buffer layout for the shader.
  55124. */
  55125. buildUniformLayout(): void;
  55126. /**
  55127. * Unbinds the material from the mesh
  55128. */
  55129. unbind(): void;
  55130. /**
  55131. * Binds the submesh data.
  55132. * @param world - The world matrix.
  55133. * @param mesh - The BJS mesh.
  55134. * @param subMesh - A submesh of the BJS mesh.
  55135. */
  55136. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55137. /**
  55138. * Returns the animatable textures.
  55139. * @returns - Array of animatable textures.
  55140. */
  55141. getAnimatables(): IAnimatable[];
  55142. /**
  55143. * Returns the texture used for reflections.
  55144. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55145. */
  55146. private _getReflectionTexture;
  55147. /**
  55148. * Returns an array of the actively used textures.
  55149. * @returns - Array of BaseTextures
  55150. */
  55151. getActiveTextures(): BaseTexture[];
  55152. /**
  55153. * Checks to see if a texture is used in the material.
  55154. * @param texture - Base texture to use.
  55155. * @returns - Boolean specifying if a texture is used in the material.
  55156. */
  55157. hasTexture(texture: BaseTexture): boolean;
  55158. /**
  55159. * Disposes the resources of the material.
  55160. * @param forceDisposeEffect - Forces the disposal of effects.
  55161. * @param forceDisposeTextures - Forces the disposal of all textures.
  55162. */
  55163. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55164. }
  55165. }
  55166. declare module BABYLON {
  55167. /**
  55168. * The Physically based material of BJS.
  55169. *
  55170. * This offers the main features of a standard PBR material.
  55171. * For more information, please refer to the documentation :
  55172. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55173. */
  55174. export class PBRMaterial extends PBRBaseMaterial {
  55175. /**
  55176. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55177. */
  55178. static readonly PBRMATERIAL_OPAQUE: number;
  55179. /**
  55180. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55181. */
  55182. static readonly PBRMATERIAL_ALPHATEST: number;
  55183. /**
  55184. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55185. */
  55186. static readonly PBRMATERIAL_ALPHABLEND: number;
  55187. /**
  55188. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55189. * They are also discarded below the alpha cutoff threshold to improve performances.
  55190. */
  55191. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55192. /**
  55193. * Defines the default value of how much AO map is occluding the analytical lights
  55194. * (point spot...).
  55195. */
  55196. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55197. /**
  55198. * Intensity of the direct lights e.g. the four lights available in your scene.
  55199. * This impacts both the direct diffuse and specular highlights.
  55200. */
  55201. directIntensity: number;
  55202. /**
  55203. * Intensity of the emissive part of the material.
  55204. * This helps controlling the emissive effect without modifying the emissive color.
  55205. */
  55206. emissiveIntensity: number;
  55207. /**
  55208. * Intensity of the environment e.g. how much the environment will light the object
  55209. * either through harmonics for rough material or through the refelction for shiny ones.
  55210. */
  55211. environmentIntensity: number;
  55212. /**
  55213. * This is a special control allowing the reduction of the specular highlights coming from the
  55214. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55215. */
  55216. specularIntensity: number;
  55217. /**
  55218. * Debug Control allowing disabling the bump map on this material.
  55219. */
  55220. disableBumpMap: boolean;
  55221. /**
  55222. * AKA Diffuse Texture in standard nomenclature.
  55223. */
  55224. albedoTexture: BaseTexture;
  55225. /**
  55226. * AKA Occlusion Texture in other nomenclature.
  55227. */
  55228. ambientTexture: BaseTexture;
  55229. /**
  55230. * AKA Occlusion Texture Intensity in other nomenclature.
  55231. */
  55232. ambientTextureStrength: number;
  55233. /**
  55234. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55235. * 1 means it completely occludes it
  55236. * 0 mean it has no impact
  55237. */
  55238. ambientTextureImpactOnAnalyticalLights: number;
  55239. /**
  55240. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55241. */
  55242. opacityTexture: BaseTexture;
  55243. /**
  55244. * Stores the reflection values in a texture.
  55245. */
  55246. reflectionTexture: Nullable<BaseTexture>;
  55247. /**
  55248. * Stores the emissive values in a texture.
  55249. */
  55250. emissiveTexture: BaseTexture;
  55251. /**
  55252. * AKA Specular texture in other nomenclature.
  55253. */
  55254. reflectivityTexture: BaseTexture;
  55255. /**
  55256. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55257. */
  55258. metallicTexture: BaseTexture;
  55259. /**
  55260. * Specifies the metallic scalar of the metallic/roughness workflow.
  55261. * Can also be used to scale the metalness values of the metallic texture.
  55262. */
  55263. metallic: Nullable<number>;
  55264. /**
  55265. * Specifies the roughness scalar of the metallic/roughness workflow.
  55266. * Can also be used to scale the roughness values of the metallic texture.
  55267. */
  55268. roughness: Nullable<number>;
  55269. /**
  55270. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55271. * By default the indexOfrefraction is used to compute F0;
  55272. *
  55273. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55274. *
  55275. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55276. * F90 = metallicReflectanceColor;
  55277. */
  55278. metallicF0Factor: number;
  55279. /**
  55280. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55281. * By default the F90 is always 1;
  55282. *
  55283. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55284. *
  55285. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55286. * F90 = metallicReflectanceColor;
  55287. */
  55288. metallicReflectanceColor: Color3;
  55289. /**
  55290. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55291. * This is multiply against the scalar values defined in the material.
  55292. */
  55293. metallicReflectanceTexture: Nullable<BaseTexture>;
  55294. /**
  55295. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55296. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55297. */
  55298. microSurfaceTexture: BaseTexture;
  55299. /**
  55300. * Stores surface normal data used to displace a mesh in a texture.
  55301. */
  55302. bumpTexture: BaseTexture;
  55303. /**
  55304. * Stores the pre-calculated light information of a mesh in a texture.
  55305. */
  55306. lightmapTexture: BaseTexture;
  55307. /**
  55308. * Stores the refracted light information in a texture.
  55309. */
  55310. get refractionTexture(): Nullable<BaseTexture>;
  55311. set refractionTexture(value: Nullable<BaseTexture>);
  55312. /**
  55313. * The color of a material in ambient lighting.
  55314. */
  55315. ambientColor: Color3;
  55316. /**
  55317. * AKA Diffuse Color in other nomenclature.
  55318. */
  55319. albedoColor: Color3;
  55320. /**
  55321. * AKA Specular Color in other nomenclature.
  55322. */
  55323. reflectivityColor: Color3;
  55324. /**
  55325. * The color reflected from the material.
  55326. */
  55327. reflectionColor: Color3;
  55328. /**
  55329. * The color emitted from the material.
  55330. */
  55331. emissiveColor: Color3;
  55332. /**
  55333. * AKA Glossiness in other nomenclature.
  55334. */
  55335. microSurface: number;
  55336. /**
  55337. * Index of refraction of the material base layer.
  55338. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55339. *
  55340. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55341. *
  55342. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55343. */
  55344. get indexOfRefraction(): number;
  55345. set indexOfRefraction(value: number);
  55346. /**
  55347. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55348. */
  55349. get invertRefractionY(): boolean;
  55350. set invertRefractionY(value: boolean);
  55351. /**
  55352. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55353. * Materials half opaque for instance using refraction could benefit from this control.
  55354. */
  55355. get linkRefractionWithTransparency(): boolean;
  55356. set linkRefractionWithTransparency(value: boolean);
  55357. /**
  55358. * If true, the light map contains occlusion information instead of lighting info.
  55359. */
  55360. useLightmapAsShadowmap: boolean;
  55361. /**
  55362. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55363. */
  55364. useAlphaFromAlbedoTexture: boolean;
  55365. /**
  55366. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55367. */
  55368. forceAlphaTest: boolean;
  55369. /**
  55370. * Defines the alpha limits in alpha test mode.
  55371. */
  55372. alphaCutOff: number;
  55373. /**
  55374. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55375. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55376. */
  55377. useSpecularOverAlpha: boolean;
  55378. /**
  55379. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55380. */
  55381. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55382. /**
  55383. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55384. */
  55385. useRoughnessFromMetallicTextureAlpha: boolean;
  55386. /**
  55387. * Specifies if the metallic texture contains the roughness information in its green channel.
  55388. */
  55389. useRoughnessFromMetallicTextureGreen: boolean;
  55390. /**
  55391. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55392. */
  55393. useMetallnessFromMetallicTextureBlue: boolean;
  55394. /**
  55395. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55396. */
  55397. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55398. /**
  55399. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55400. */
  55401. useAmbientInGrayScale: boolean;
  55402. /**
  55403. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55404. * The material will try to infer what glossiness each pixel should be.
  55405. */
  55406. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55407. /**
  55408. * BJS is using an harcoded light falloff based on a manually sets up range.
  55409. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55410. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55411. */
  55412. get usePhysicalLightFalloff(): boolean;
  55413. /**
  55414. * BJS is using an harcoded light falloff based on a manually sets up range.
  55415. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55416. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55417. */
  55418. set usePhysicalLightFalloff(value: boolean);
  55419. /**
  55420. * In order to support the falloff compatibility with gltf, a special mode has been added
  55421. * to reproduce the gltf light falloff.
  55422. */
  55423. get useGLTFLightFalloff(): boolean;
  55424. /**
  55425. * In order to support the falloff compatibility with gltf, a special mode has been added
  55426. * to reproduce the gltf light falloff.
  55427. */
  55428. set useGLTFLightFalloff(value: boolean);
  55429. /**
  55430. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55431. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55432. */
  55433. useRadianceOverAlpha: boolean;
  55434. /**
  55435. * Allows using an object space normal map (instead of tangent space).
  55436. */
  55437. useObjectSpaceNormalMap: boolean;
  55438. /**
  55439. * Allows using the bump map in parallax mode.
  55440. */
  55441. useParallax: boolean;
  55442. /**
  55443. * Allows using the bump map in parallax occlusion mode.
  55444. */
  55445. useParallaxOcclusion: boolean;
  55446. /**
  55447. * Controls the scale bias of the parallax mode.
  55448. */
  55449. parallaxScaleBias: number;
  55450. /**
  55451. * If sets to true, disables all the lights affecting the material.
  55452. */
  55453. disableLighting: boolean;
  55454. /**
  55455. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55456. */
  55457. forceIrradianceInFragment: boolean;
  55458. /**
  55459. * Number of Simultaneous lights allowed on the material.
  55460. */
  55461. maxSimultaneousLights: number;
  55462. /**
  55463. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55464. */
  55465. invertNormalMapX: boolean;
  55466. /**
  55467. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55468. */
  55469. invertNormalMapY: boolean;
  55470. /**
  55471. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55472. */
  55473. twoSidedLighting: boolean;
  55474. /**
  55475. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55476. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55477. */
  55478. useAlphaFresnel: boolean;
  55479. /**
  55480. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55481. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55482. */
  55483. useLinearAlphaFresnel: boolean;
  55484. /**
  55485. * Let user defines the brdf lookup texture used for IBL.
  55486. * A default 8bit version is embedded but you could point at :
  55487. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55488. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55489. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55490. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55491. */
  55492. environmentBRDFTexture: Nullable<BaseTexture>;
  55493. /**
  55494. * Force normal to face away from face.
  55495. */
  55496. forceNormalForward: boolean;
  55497. /**
  55498. * Enables specular anti aliasing in the PBR shader.
  55499. * It will both interacts on the Geometry for analytical and IBL lighting.
  55500. * It also prefilter the roughness map based on the bump values.
  55501. */
  55502. enableSpecularAntiAliasing: boolean;
  55503. /**
  55504. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55505. * makes the reflect vector face the model (under horizon).
  55506. */
  55507. useHorizonOcclusion: boolean;
  55508. /**
  55509. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55510. * too much the area relying on ambient texture to define their ambient occlusion.
  55511. */
  55512. useRadianceOcclusion: boolean;
  55513. /**
  55514. * If set to true, no lighting calculations will be applied.
  55515. */
  55516. unlit: boolean;
  55517. /**
  55518. * Gets the image processing configuration used either in this material.
  55519. */
  55520. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55521. /**
  55522. * Sets the Default image processing configuration used either in the this material.
  55523. *
  55524. * If sets to null, the scene one is in use.
  55525. */
  55526. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55527. /**
  55528. * Gets wether the color curves effect is enabled.
  55529. */
  55530. get cameraColorCurvesEnabled(): boolean;
  55531. /**
  55532. * Sets wether the color curves effect is enabled.
  55533. */
  55534. set cameraColorCurvesEnabled(value: boolean);
  55535. /**
  55536. * Gets wether the color grading effect is enabled.
  55537. */
  55538. get cameraColorGradingEnabled(): boolean;
  55539. /**
  55540. * Gets wether the color grading effect is enabled.
  55541. */
  55542. set cameraColorGradingEnabled(value: boolean);
  55543. /**
  55544. * Gets wether tonemapping is enabled or not.
  55545. */
  55546. get cameraToneMappingEnabled(): boolean;
  55547. /**
  55548. * Sets wether tonemapping is enabled or not
  55549. */
  55550. set cameraToneMappingEnabled(value: boolean);
  55551. /**
  55552. * The camera exposure used on this material.
  55553. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55554. * This corresponds to a photographic exposure.
  55555. */
  55556. get cameraExposure(): number;
  55557. /**
  55558. * The camera exposure used on this material.
  55559. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55560. * This corresponds to a photographic exposure.
  55561. */
  55562. set cameraExposure(value: number);
  55563. /**
  55564. * Gets The camera contrast used on this material.
  55565. */
  55566. get cameraContrast(): number;
  55567. /**
  55568. * Sets The camera contrast used on this material.
  55569. */
  55570. set cameraContrast(value: number);
  55571. /**
  55572. * Gets the Color Grading 2D Lookup Texture.
  55573. */
  55574. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55575. /**
  55576. * Sets the Color Grading 2D Lookup Texture.
  55577. */
  55578. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55579. /**
  55580. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55581. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55582. * 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;
  55583. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55584. */
  55585. get cameraColorCurves(): Nullable<ColorCurves>;
  55586. /**
  55587. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55588. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55589. * 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;
  55590. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55591. */
  55592. set cameraColorCurves(value: Nullable<ColorCurves>);
  55593. /**
  55594. * Instantiates a new PBRMaterial instance.
  55595. *
  55596. * @param name The material name
  55597. * @param scene The scene the material will be use in.
  55598. */
  55599. constructor(name: string, scene: Scene);
  55600. /**
  55601. * Returns the name of this material class.
  55602. */
  55603. getClassName(): string;
  55604. /**
  55605. * Makes a duplicate of the current material.
  55606. * @param name - name to use for the new material.
  55607. */
  55608. clone(name: string): PBRMaterial;
  55609. /**
  55610. * Serializes this PBR Material.
  55611. * @returns - An object with the serialized material.
  55612. */
  55613. serialize(): any;
  55614. /**
  55615. * Parses a PBR Material from a serialized object.
  55616. * @param source - Serialized object.
  55617. * @param scene - BJS scene instance.
  55618. * @param rootUrl - url for the scene object
  55619. * @returns - PBRMaterial
  55620. */
  55621. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55622. }
  55623. }
  55624. declare module BABYLON {
  55625. /**
  55626. * Direct draw surface info
  55627. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55628. */
  55629. export interface DDSInfo {
  55630. /**
  55631. * Width of the texture
  55632. */
  55633. width: number;
  55634. /**
  55635. * Width of the texture
  55636. */
  55637. height: number;
  55638. /**
  55639. * Number of Mipmaps for the texture
  55640. * @see https://en.wikipedia.org/wiki/Mipmap
  55641. */
  55642. mipmapCount: number;
  55643. /**
  55644. * If the textures format is a known fourCC format
  55645. * @see https://www.fourcc.org/
  55646. */
  55647. isFourCC: boolean;
  55648. /**
  55649. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55650. */
  55651. isRGB: boolean;
  55652. /**
  55653. * If the texture is a lumincance format
  55654. */
  55655. isLuminance: boolean;
  55656. /**
  55657. * If this is a cube texture
  55658. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55659. */
  55660. isCube: boolean;
  55661. /**
  55662. * If the texture is a compressed format eg. FOURCC_DXT1
  55663. */
  55664. isCompressed: boolean;
  55665. /**
  55666. * The dxgiFormat of the texture
  55667. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55668. */
  55669. dxgiFormat: number;
  55670. /**
  55671. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55672. */
  55673. textureType: number;
  55674. /**
  55675. * Sphericle polynomial created for the dds texture
  55676. */
  55677. sphericalPolynomial?: SphericalPolynomial;
  55678. }
  55679. /**
  55680. * Class used to provide DDS decompression tools
  55681. */
  55682. export class DDSTools {
  55683. /**
  55684. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55685. */
  55686. static StoreLODInAlphaChannel: boolean;
  55687. /**
  55688. * Gets DDS information from an array buffer
  55689. * @param data defines the array buffer view to read data from
  55690. * @returns the DDS information
  55691. */
  55692. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55693. private static _FloatView;
  55694. private static _Int32View;
  55695. private static _ToHalfFloat;
  55696. private static _FromHalfFloat;
  55697. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55698. private static _GetHalfFloatRGBAArrayBuffer;
  55699. private static _GetFloatRGBAArrayBuffer;
  55700. private static _GetFloatAsUIntRGBAArrayBuffer;
  55701. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55702. private static _GetRGBAArrayBuffer;
  55703. private static _ExtractLongWordOrder;
  55704. private static _GetRGBArrayBuffer;
  55705. private static _GetLuminanceArrayBuffer;
  55706. /**
  55707. * Uploads DDS Levels to a Babylon Texture
  55708. * @hidden
  55709. */
  55710. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55711. }
  55712. interface ThinEngine {
  55713. /**
  55714. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55715. * @param rootUrl defines the url where the file to load is located
  55716. * @param scene defines the current scene
  55717. * @param lodScale defines scale to apply to the mip map selection
  55718. * @param lodOffset defines offset to apply to the mip map selection
  55719. * @param onLoad defines an optional callback raised when the texture is loaded
  55720. * @param onError defines an optional callback raised if there is an issue to load the texture
  55721. * @param format defines the format of the data
  55722. * @param forcedExtension defines the extension to use to pick the right loader
  55723. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55724. * @returns the cube texture as an InternalTexture
  55725. */
  55726. 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;
  55727. }
  55728. }
  55729. declare module BABYLON {
  55730. /**
  55731. * Implementation of the DDS Texture Loader.
  55732. * @hidden
  55733. */
  55734. export class _DDSTextureLoader implements IInternalTextureLoader {
  55735. /**
  55736. * Defines wether the loader supports cascade loading the different faces.
  55737. */
  55738. readonly supportCascades: boolean;
  55739. /**
  55740. * This returns if the loader support the current file information.
  55741. * @param extension defines the file extension of the file being loaded
  55742. * @returns true if the loader can load the specified file
  55743. */
  55744. canLoad(extension: string): boolean;
  55745. /**
  55746. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55747. * @param data contains the texture data
  55748. * @param texture defines the BabylonJS internal texture
  55749. * @param createPolynomials will be true if polynomials have been requested
  55750. * @param onLoad defines the callback to trigger once the texture is ready
  55751. * @param onError defines the callback to trigger in case of error
  55752. */
  55753. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55754. /**
  55755. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55756. * @param data contains the texture data
  55757. * @param texture defines the BabylonJS internal texture
  55758. * @param callback defines the method to call once ready to upload
  55759. */
  55760. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55761. }
  55762. }
  55763. declare module BABYLON {
  55764. /**
  55765. * Implementation of the ENV Texture Loader.
  55766. * @hidden
  55767. */
  55768. export class _ENVTextureLoader implements IInternalTextureLoader {
  55769. /**
  55770. * Defines wether the loader supports cascade loading the different faces.
  55771. */
  55772. readonly supportCascades: boolean;
  55773. /**
  55774. * This returns if the loader support the current file information.
  55775. * @param extension defines the file extension of the file being loaded
  55776. * @returns true if the loader can load the specified file
  55777. */
  55778. canLoad(extension: string): boolean;
  55779. /**
  55780. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55781. * @param data contains the texture data
  55782. * @param texture defines the BabylonJS internal texture
  55783. * @param createPolynomials will be true if polynomials have been requested
  55784. * @param onLoad defines the callback to trigger once the texture is ready
  55785. * @param onError defines the callback to trigger in case of error
  55786. */
  55787. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55788. /**
  55789. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55790. * @param data contains the texture data
  55791. * @param texture defines the BabylonJS internal texture
  55792. * @param callback defines the method to call once ready to upload
  55793. */
  55794. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55795. }
  55796. }
  55797. declare module BABYLON {
  55798. /**
  55799. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55800. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55801. */
  55802. export class KhronosTextureContainer {
  55803. /** contents of the KTX container file */
  55804. data: ArrayBufferView;
  55805. private static HEADER_LEN;
  55806. private static COMPRESSED_2D;
  55807. private static COMPRESSED_3D;
  55808. private static TEX_2D;
  55809. private static TEX_3D;
  55810. /**
  55811. * Gets the openGL type
  55812. */
  55813. glType: number;
  55814. /**
  55815. * Gets the openGL type size
  55816. */
  55817. glTypeSize: number;
  55818. /**
  55819. * Gets the openGL format
  55820. */
  55821. glFormat: number;
  55822. /**
  55823. * Gets the openGL internal format
  55824. */
  55825. glInternalFormat: number;
  55826. /**
  55827. * Gets the base internal format
  55828. */
  55829. glBaseInternalFormat: number;
  55830. /**
  55831. * Gets image width in pixel
  55832. */
  55833. pixelWidth: number;
  55834. /**
  55835. * Gets image height in pixel
  55836. */
  55837. pixelHeight: number;
  55838. /**
  55839. * Gets image depth in pixels
  55840. */
  55841. pixelDepth: number;
  55842. /**
  55843. * Gets the number of array elements
  55844. */
  55845. numberOfArrayElements: number;
  55846. /**
  55847. * Gets the number of faces
  55848. */
  55849. numberOfFaces: number;
  55850. /**
  55851. * Gets the number of mipmap levels
  55852. */
  55853. numberOfMipmapLevels: number;
  55854. /**
  55855. * Gets the bytes of key value data
  55856. */
  55857. bytesOfKeyValueData: number;
  55858. /**
  55859. * Gets the load type
  55860. */
  55861. loadType: number;
  55862. /**
  55863. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55864. */
  55865. isInvalid: boolean;
  55866. /**
  55867. * Creates a new KhronosTextureContainer
  55868. * @param data contents of the KTX container file
  55869. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55870. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55871. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55872. */
  55873. constructor(
  55874. /** contents of the KTX container file */
  55875. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55876. /**
  55877. * Uploads KTX content to a Babylon Texture.
  55878. * It is assumed that the texture has already been created & is currently bound
  55879. * @hidden
  55880. */
  55881. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55882. private _upload2DCompressedLevels;
  55883. /**
  55884. * Checks if the given data starts with a KTX file identifier.
  55885. * @param data the data to check
  55886. * @returns true if the data is a KTX file or false otherwise
  55887. */
  55888. static IsValid(data: ArrayBufferView): boolean;
  55889. }
  55890. }
  55891. declare module BABYLON {
  55892. /**
  55893. * Class for loading KTX2 files
  55894. * !!! Experimental Extension Subject to Changes !!!
  55895. * @hidden
  55896. */
  55897. export class KhronosTextureContainer2 {
  55898. private static _ModulePromise;
  55899. private static _TranscodeFormat;
  55900. constructor(engine: ThinEngine);
  55901. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55902. private _determineTranscodeFormat;
  55903. /**
  55904. * Checks if the given data starts with a KTX2 file identifier.
  55905. * @param data the data to check
  55906. * @returns true if the data is a KTX2 file or false otherwise
  55907. */
  55908. static IsValid(data: ArrayBufferView): boolean;
  55909. }
  55910. }
  55911. declare module BABYLON {
  55912. /**
  55913. * Implementation of the KTX Texture Loader.
  55914. * @hidden
  55915. */
  55916. export class _KTXTextureLoader implements IInternalTextureLoader {
  55917. /**
  55918. * Defines wether the loader supports cascade loading the different faces.
  55919. */
  55920. readonly supportCascades: boolean;
  55921. /**
  55922. * This returns if the loader support the current file information.
  55923. * @param extension defines the file extension of the file being loaded
  55924. * @returns true if the loader can load the specified file
  55925. */
  55926. canLoad(extension: string): boolean;
  55927. /**
  55928. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55929. * @param data contains the texture data
  55930. * @param texture defines the BabylonJS internal texture
  55931. * @param createPolynomials will be true if polynomials have been requested
  55932. * @param onLoad defines the callback to trigger once the texture is ready
  55933. * @param onError defines the callback to trigger in case of error
  55934. */
  55935. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55936. /**
  55937. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55938. * @param data contains the texture data
  55939. * @param texture defines the BabylonJS internal texture
  55940. * @param callback defines the method to call once ready to upload
  55941. */
  55942. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55943. }
  55944. }
  55945. declare module BABYLON {
  55946. /** @hidden */
  55947. export var _forceSceneHelpersToBundle: boolean;
  55948. interface Scene {
  55949. /**
  55950. * Creates a default light for the scene.
  55951. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55952. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55953. */
  55954. createDefaultLight(replace?: boolean): void;
  55955. /**
  55956. * Creates a default camera for the scene.
  55957. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55958. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55959. * @param replace has default false, when true replaces the active camera in the scene
  55960. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55961. */
  55962. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55963. /**
  55964. * Creates a default camera and a default light.
  55965. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55966. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55967. * @param replace has the default false, when true replaces the active camera/light in the scene
  55968. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55969. */
  55970. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55971. /**
  55972. * Creates a new sky box
  55973. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55974. * @param environmentTexture defines the texture to use as environment texture
  55975. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55976. * @param scale defines the overall scale of the skybox
  55977. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55978. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55979. * @returns a new mesh holding the sky box
  55980. */
  55981. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55982. /**
  55983. * Creates a new environment
  55984. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55985. * @param options defines the options you can use to configure the environment
  55986. * @returns the new EnvironmentHelper
  55987. */
  55988. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55989. /**
  55990. * Creates a new VREXperienceHelper
  55991. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55992. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55993. * @returns a new VREXperienceHelper
  55994. */
  55995. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55996. /**
  55997. * Creates a new WebXRDefaultExperience
  55998. * @see http://doc.babylonjs.com/how_to/webxr
  55999. * @param options experience options
  56000. * @returns a promise for a new WebXRDefaultExperience
  56001. */
  56002. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56003. }
  56004. }
  56005. declare module BABYLON {
  56006. /**
  56007. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56008. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56009. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56010. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56011. */
  56012. export class VideoDome extends TransformNode {
  56013. /**
  56014. * Define the video source as a Monoscopic panoramic 360 video.
  56015. */
  56016. static readonly MODE_MONOSCOPIC: number;
  56017. /**
  56018. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56019. */
  56020. static readonly MODE_TOPBOTTOM: number;
  56021. /**
  56022. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56023. */
  56024. static readonly MODE_SIDEBYSIDE: number;
  56025. private _halfDome;
  56026. private _useDirectMapping;
  56027. /**
  56028. * The video texture being displayed on the sphere
  56029. */
  56030. protected _videoTexture: VideoTexture;
  56031. /**
  56032. * Gets the video texture being displayed on the sphere
  56033. */
  56034. get videoTexture(): VideoTexture;
  56035. /**
  56036. * The skybox material
  56037. */
  56038. protected _material: BackgroundMaterial;
  56039. /**
  56040. * The surface used for the skybox
  56041. */
  56042. protected _mesh: Mesh;
  56043. /**
  56044. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56045. */
  56046. private _halfDomeMask;
  56047. /**
  56048. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56049. * Also see the options.resolution property.
  56050. */
  56051. get fovMultiplier(): number;
  56052. set fovMultiplier(value: number);
  56053. private _videoMode;
  56054. /**
  56055. * Gets or set the current video mode for the video. It can be:
  56056. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56057. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56058. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56059. */
  56060. get videoMode(): number;
  56061. set videoMode(value: number);
  56062. /**
  56063. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56064. *
  56065. */
  56066. get halfDome(): boolean;
  56067. /**
  56068. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56069. */
  56070. set halfDome(enabled: boolean);
  56071. /**
  56072. * Oberserver used in Stereoscopic VR Mode.
  56073. */
  56074. private _onBeforeCameraRenderObserver;
  56075. /**
  56076. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56077. * @param name Element's name, child elements will append suffixes for their own names.
  56078. * @param urlsOrVideo defines the url(s) or the video element to use
  56079. * @param options An object containing optional or exposed sub element properties
  56080. */
  56081. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56082. resolution?: number;
  56083. clickToPlay?: boolean;
  56084. autoPlay?: boolean;
  56085. loop?: boolean;
  56086. size?: number;
  56087. poster?: string;
  56088. faceForward?: boolean;
  56089. useDirectMapping?: boolean;
  56090. halfDomeMode?: boolean;
  56091. }, scene: Scene);
  56092. private _changeVideoMode;
  56093. /**
  56094. * Releases resources associated with this node.
  56095. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56096. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56097. */
  56098. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56099. }
  56100. }
  56101. declare module BABYLON {
  56102. /**
  56103. * This class can be used to get instrumentation data from a Babylon engine
  56104. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56105. */
  56106. export class EngineInstrumentation implements IDisposable {
  56107. /**
  56108. * Define the instrumented engine.
  56109. */
  56110. engine: Engine;
  56111. private _captureGPUFrameTime;
  56112. private _gpuFrameTimeToken;
  56113. private _gpuFrameTime;
  56114. private _captureShaderCompilationTime;
  56115. private _shaderCompilationTime;
  56116. private _onBeginFrameObserver;
  56117. private _onEndFrameObserver;
  56118. private _onBeforeShaderCompilationObserver;
  56119. private _onAfterShaderCompilationObserver;
  56120. /**
  56121. * Gets the perf counter used for GPU frame time
  56122. */
  56123. get gpuFrameTimeCounter(): PerfCounter;
  56124. /**
  56125. * Gets the GPU frame time capture status
  56126. */
  56127. get captureGPUFrameTime(): boolean;
  56128. /**
  56129. * Enable or disable the GPU frame time capture
  56130. */
  56131. set captureGPUFrameTime(value: boolean);
  56132. /**
  56133. * Gets the perf counter used for shader compilation time
  56134. */
  56135. get shaderCompilationTimeCounter(): PerfCounter;
  56136. /**
  56137. * Gets the shader compilation time capture status
  56138. */
  56139. get captureShaderCompilationTime(): boolean;
  56140. /**
  56141. * Enable or disable the shader compilation time capture
  56142. */
  56143. set captureShaderCompilationTime(value: boolean);
  56144. /**
  56145. * Instantiates a new engine instrumentation.
  56146. * This class can be used to get instrumentation data from a Babylon engine
  56147. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56148. * @param engine Defines the engine to instrument
  56149. */
  56150. constructor(
  56151. /**
  56152. * Define the instrumented engine.
  56153. */
  56154. engine: Engine);
  56155. /**
  56156. * Dispose and release associated resources.
  56157. */
  56158. dispose(): void;
  56159. }
  56160. }
  56161. declare module BABYLON {
  56162. /**
  56163. * This class can be used to get instrumentation data from a Babylon engine
  56164. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56165. */
  56166. export class SceneInstrumentation implements IDisposable {
  56167. /**
  56168. * Defines the scene to instrument
  56169. */
  56170. scene: Scene;
  56171. private _captureActiveMeshesEvaluationTime;
  56172. private _activeMeshesEvaluationTime;
  56173. private _captureRenderTargetsRenderTime;
  56174. private _renderTargetsRenderTime;
  56175. private _captureFrameTime;
  56176. private _frameTime;
  56177. private _captureRenderTime;
  56178. private _renderTime;
  56179. private _captureInterFrameTime;
  56180. private _interFrameTime;
  56181. private _captureParticlesRenderTime;
  56182. private _particlesRenderTime;
  56183. private _captureSpritesRenderTime;
  56184. private _spritesRenderTime;
  56185. private _capturePhysicsTime;
  56186. private _physicsTime;
  56187. private _captureAnimationsTime;
  56188. private _animationsTime;
  56189. private _captureCameraRenderTime;
  56190. private _cameraRenderTime;
  56191. private _onBeforeActiveMeshesEvaluationObserver;
  56192. private _onAfterActiveMeshesEvaluationObserver;
  56193. private _onBeforeRenderTargetsRenderObserver;
  56194. private _onAfterRenderTargetsRenderObserver;
  56195. private _onAfterRenderObserver;
  56196. private _onBeforeDrawPhaseObserver;
  56197. private _onAfterDrawPhaseObserver;
  56198. private _onBeforeAnimationsObserver;
  56199. private _onBeforeParticlesRenderingObserver;
  56200. private _onAfterParticlesRenderingObserver;
  56201. private _onBeforeSpritesRenderingObserver;
  56202. private _onAfterSpritesRenderingObserver;
  56203. private _onBeforePhysicsObserver;
  56204. private _onAfterPhysicsObserver;
  56205. private _onAfterAnimationsObserver;
  56206. private _onBeforeCameraRenderObserver;
  56207. private _onAfterCameraRenderObserver;
  56208. /**
  56209. * Gets the perf counter used for active meshes evaluation time
  56210. */
  56211. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56212. /**
  56213. * Gets the active meshes evaluation time capture status
  56214. */
  56215. get captureActiveMeshesEvaluationTime(): boolean;
  56216. /**
  56217. * Enable or disable the active meshes evaluation time capture
  56218. */
  56219. set captureActiveMeshesEvaluationTime(value: boolean);
  56220. /**
  56221. * Gets the perf counter used for render targets render time
  56222. */
  56223. get renderTargetsRenderTimeCounter(): PerfCounter;
  56224. /**
  56225. * Gets the render targets render time capture status
  56226. */
  56227. get captureRenderTargetsRenderTime(): boolean;
  56228. /**
  56229. * Enable or disable the render targets render time capture
  56230. */
  56231. set captureRenderTargetsRenderTime(value: boolean);
  56232. /**
  56233. * Gets the perf counter used for particles render time
  56234. */
  56235. get particlesRenderTimeCounter(): PerfCounter;
  56236. /**
  56237. * Gets the particles render time capture status
  56238. */
  56239. get captureParticlesRenderTime(): boolean;
  56240. /**
  56241. * Enable or disable the particles render time capture
  56242. */
  56243. set captureParticlesRenderTime(value: boolean);
  56244. /**
  56245. * Gets the perf counter used for sprites render time
  56246. */
  56247. get spritesRenderTimeCounter(): PerfCounter;
  56248. /**
  56249. * Gets the sprites render time capture status
  56250. */
  56251. get captureSpritesRenderTime(): boolean;
  56252. /**
  56253. * Enable or disable the sprites render time capture
  56254. */
  56255. set captureSpritesRenderTime(value: boolean);
  56256. /**
  56257. * Gets the perf counter used for physics time
  56258. */
  56259. get physicsTimeCounter(): PerfCounter;
  56260. /**
  56261. * Gets the physics time capture status
  56262. */
  56263. get capturePhysicsTime(): boolean;
  56264. /**
  56265. * Enable or disable the physics time capture
  56266. */
  56267. set capturePhysicsTime(value: boolean);
  56268. /**
  56269. * Gets the perf counter used for animations time
  56270. */
  56271. get animationsTimeCounter(): PerfCounter;
  56272. /**
  56273. * Gets the animations time capture status
  56274. */
  56275. get captureAnimationsTime(): boolean;
  56276. /**
  56277. * Enable or disable the animations time capture
  56278. */
  56279. set captureAnimationsTime(value: boolean);
  56280. /**
  56281. * Gets the perf counter used for frame time capture
  56282. */
  56283. get frameTimeCounter(): PerfCounter;
  56284. /**
  56285. * Gets the frame time capture status
  56286. */
  56287. get captureFrameTime(): boolean;
  56288. /**
  56289. * Enable or disable the frame time capture
  56290. */
  56291. set captureFrameTime(value: boolean);
  56292. /**
  56293. * Gets the perf counter used for inter-frames time capture
  56294. */
  56295. get interFrameTimeCounter(): PerfCounter;
  56296. /**
  56297. * Gets the inter-frames time capture status
  56298. */
  56299. get captureInterFrameTime(): boolean;
  56300. /**
  56301. * Enable or disable the inter-frames time capture
  56302. */
  56303. set captureInterFrameTime(value: boolean);
  56304. /**
  56305. * Gets the perf counter used for render time capture
  56306. */
  56307. get renderTimeCounter(): PerfCounter;
  56308. /**
  56309. * Gets the render time capture status
  56310. */
  56311. get captureRenderTime(): boolean;
  56312. /**
  56313. * Enable or disable the render time capture
  56314. */
  56315. set captureRenderTime(value: boolean);
  56316. /**
  56317. * Gets the perf counter used for camera render time capture
  56318. */
  56319. get cameraRenderTimeCounter(): PerfCounter;
  56320. /**
  56321. * Gets the camera render time capture status
  56322. */
  56323. get captureCameraRenderTime(): boolean;
  56324. /**
  56325. * Enable or disable the camera render time capture
  56326. */
  56327. set captureCameraRenderTime(value: boolean);
  56328. /**
  56329. * Gets the perf counter used for draw calls
  56330. */
  56331. get drawCallsCounter(): PerfCounter;
  56332. /**
  56333. * Instantiates a new scene instrumentation.
  56334. * This class can be used to get instrumentation data from a Babylon engine
  56335. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56336. * @param scene Defines the scene to instrument
  56337. */
  56338. constructor(
  56339. /**
  56340. * Defines the scene to instrument
  56341. */
  56342. scene: Scene);
  56343. /**
  56344. * Dispose and release associated resources.
  56345. */
  56346. dispose(): void;
  56347. }
  56348. }
  56349. declare module BABYLON {
  56350. /** @hidden */
  56351. export var glowMapGenerationPixelShader: {
  56352. name: string;
  56353. shader: string;
  56354. };
  56355. }
  56356. declare module BABYLON {
  56357. /** @hidden */
  56358. export var glowMapGenerationVertexShader: {
  56359. name: string;
  56360. shader: string;
  56361. };
  56362. }
  56363. declare module BABYLON {
  56364. /**
  56365. * Effect layer options. This helps customizing the behaviour
  56366. * of the effect layer.
  56367. */
  56368. export interface IEffectLayerOptions {
  56369. /**
  56370. * Multiplication factor apply to the canvas size to compute the render target size
  56371. * used to generated the objects (the smaller the faster).
  56372. */
  56373. mainTextureRatio: number;
  56374. /**
  56375. * Enforces a fixed size texture to ensure effect stability across devices.
  56376. */
  56377. mainTextureFixedSize?: number;
  56378. /**
  56379. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56380. */
  56381. alphaBlendingMode: number;
  56382. /**
  56383. * The camera attached to the layer.
  56384. */
  56385. camera: Nullable<Camera>;
  56386. /**
  56387. * The rendering group to draw the layer in.
  56388. */
  56389. renderingGroupId: number;
  56390. }
  56391. /**
  56392. * The effect layer Helps adding post process effect blended with the main pass.
  56393. *
  56394. * This can be for instance use to generate glow or higlight effects on the scene.
  56395. *
  56396. * The effect layer class can not be used directly and is intented to inherited from to be
  56397. * customized per effects.
  56398. */
  56399. export abstract class EffectLayer {
  56400. private _vertexBuffers;
  56401. private _indexBuffer;
  56402. private _cachedDefines;
  56403. private _effectLayerMapGenerationEffect;
  56404. private _effectLayerOptions;
  56405. private _mergeEffect;
  56406. protected _scene: Scene;
  56407. protected _engine: Engine;
  56408. protected _maxSize: number;
  56409. protected _mainTextureDesiredSize: ISize;
  56410. protected _mainTexture: RenderTargetTexture;
  56411. protected _shouldRender: boolean;
  56412. protected _postProcesses: PostProcess[];
  56413. protected _textures: BaseTexture[];
  56414. protected _emissiveTextureAndColor: {
  56415. texture: Nullable<BaseTexture>;
  56416. color: Color4;
  56417. };
  56418. /**
  56419. * The name of the layer
  56420. */
  56421. name: string;
  56422. /**
  56423. * The clear color of the texture used to generate the glow map.
  56424. */
  56425. neutralColor: Color4;
  56426. /**
  56427. * Specifies whether the highlight layer is enabled or not.
  56428. */
  56429. isEnabled: boolean;
  56430. /**
  56431. * Gets the camera attached to the layer.
  56432. */
  56433. get camera(): Nullable<Camera>;
  56434. /**
  56435. * Gets the rendering group id the layer should render in.
  56436. */
  56437. get renderingGroupId(): number;
  56438. set renderingGroupId(renderingGroupId: number);
  56439. /**
  56440. * An event triggered when the effect layer has been disposed.
  56441. */
  56442. onDisposeObservable: Observable<EffectLayer>;
  56443. /**
  56444. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56445. */
  56446. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56447. /**
  56448. * An event triggered when the generated texture is being merged in the scene.
  56449. */
  56450. onBeforeComposeObservable: Observable<EffectLayer>;
  56451. /**
  56452. * An event triggered when the mesh is rendered into the effect render target.
  56453. */
  56454. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56455. /**
  56456. * An event triggered after the mesh has been rendered into the effect render target.
  56457. */
  56458. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56459. /**
  56460. * An event triggered when the generated texture has been merged in the scene.
  56461. */
  56462. onAfterComposeObservable: Observable<EffectLayer>;
  56463. /**
  56464. * An event triggered when the efffect layer changes its size.
  56465. */
  56466. onSizeChangedObservable: Observable<EffectLayer>;
  56467. /** @hidden */
  56468. static _SceneComponentInitialization: (scene: Scene) => void;
  56469. /**
  56470. * Instantiates a new effect Layer and references it in the scene.
  56471. * @param name The name of the layer
  56472. * @param scene The scene to use the layer in
  56473. */
  56474. constructor(
  56475. /** The Friendly of the effect in the scene */
  56476. name: string, scene: Scene);
  56477. /**
  56478. * Get the effect name of the layer.
  56479. * @return The effect name
  56480. */
  56481. abstract getEffectName(): string;
  56482. /**
  56483. * Checks for the readiness of the element composing the layer.
  56484. * @param subMesh the mesh to check for
  56485. * @param useInstances specify whether or not to use instances to render the mesh
  56486. * @return true if ready otherwise, false
  56487. */
  56488. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56489. /**
  56490. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56491. * @returns true if the effect requires stencil during the main canvas render pass.
  56492. */
  56493. abstract needStencil(): boolean;
  56494. /**
  56495. * Create the merge effect. This is the shader use to blit the information back
  56496. * to the main canvas at the end of the scene rendering.
  56497. * @returns The effect containing the shader used to merge the effect on the main canvas
  56498. */
  56499. protected abstract _createMergeEffect(): Effect;
  56500. /**
  56501. * Creates the render target textures and post processes used in the effect layer.
  56502. */
  56503. protected abstract _createTextureAndPostProcesses(): void;
  56504. /**
  56505. * Implementation specific of rendering the generating effect on the main canvas.
  56506. * @param effect The effect used to render through
  56507. */
  56508. protected abstract _internalRender(effect: Effect): void;
  56509. /**
  56510. * Sets the required values for both the emissive texture and and the main color.
  56511. */
  56512. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56513. /**
  56514. * Free any resources and references associated to a mesh.
  56515. * Internal use
  56516. * @param mesh The mesh to free.
  56517. */
  56518. abstract _disposeMesh(mesh: Mesh): void;
  56519. /**
  56520. * Serializes this layer (Glow or Highlight for example)
  56521. * @returns a serialized layer object
  56522. */
  56523. abstract serialize?(): any;
  56524. /**
  56525. * Initializes the effect layer with the required options.
  56526. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56527. */
  56528. protected _init(options: Partial<IEffectLayerOptions>): void;
  56529. /**
  56530. * Generates the index buffer of the full screen quad blending to the main canvas.
  56531. */
  56532. private _generateIndexBuffer;
  56533. /**
  56534. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56535. */
  56536. private _generateVertexBuffer;
  56537. /**
  56538. * Sets the main texture desired size which is the closest power of two
  56539. * of the engine canvas size.
  56540. */
  56541. private _setMainTextureSize;
  56542. /**
  56543. * Creates the main texture for the effect layer.
  56544. */
  56545. protected _createMainTexture(): void;
  56546. /**
  56547. * Adds specific effects defines.
  56548. * @param defines The defines to add specifics to.
  56549. */
  56550. protected _addCustomEffectDefines(defines: string[]): void;
  56551. /**
  56552. * Checks for the readiness of the element composing the layer.
  56553. * @param subMesh the mesh to check for
  56554. * @param useInstances specify whether or not to use instances to render the mesh
  56555. * @param emissiveTexture the associated emissive texture used to generate the glow
  56556. * @return true if ready otherwise, false
  56557. */
  56558. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56559. /**
  56560. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56561. */
  56562. render(): void;
  56563. /**
  56564. * Determine if a given mesh will be used in the current effect.
  56565. * @param mesh mesh to test
  56566. * @returns true if the mesh will be used
  56567. */
  56568. hasMesh(mesh: AbstractMesh): boolean;
  56569. /**
  56570. * Returns true if the layer contains information to display, otherwise false.
  56571. * @returns true if the glow layer should be rendered
  56572. */
  56573. shouldRender(): boolean;
  56574. /**
  56575. * Returns true if the mesh should render, otherwise false.
  56576. * @param mesh The mesh to render
  56577. * @returns true if it should render otherwise false
  56578. */
  56579. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56580. /**
  56581. * Returns true if the mesh can be rendered, otherwise false.
  56582. * @param mesh The mesh to render
  56583. * @param material The material used on the mesh
  56584. * @returns true if it can be rendered otherwise false
  56585. */
  56586. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56587. /**
  56588. * Returns true if the mesh should render, otherwise false.
  56589. * @param mesh The mesh to render
  56590. * @returns true if it should render otherwise false
  56591. */
  56592. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56593. /**
  56594. * Renders the submesh passed in parameter to the generation map.
  56595. */
  56596. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56597. /**
  56598. * Defines whether the current material of the mesh should be use to render the effect.
  56599. * @param mesh defines the current mesh to render
  56600. */
  56601. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56602. /**
  56603. * Rebuild the required buffers.
  56604. * @hidden Internal use only.
  56605. */
  56606. _rebuild(): void;
  56607. /**
  56608. * Dispose only the render target textures and post process.
  56609. */
  56610. private _disposeTextureAndPostProcesses;
  56611. /**
  56612. * Dispose the highlight layer and free resources.
  56613. */
  56614. dispose(): void;
  56615. /**
  56616. * Gets the class name of the effect layer
  56617. * @returns the string with the class name of the effect layer
  56618. */
  56619. getClassName(): string;
  56620. /**
  56621. * Creates an effect layer from parsed effect layer data
  56622. * @param parsedEffectLayer defines effect layer data
  56623. * @param scene defines the current scene
  56624. * @param rootUrl defines the root URL containing the effect layer information
  56625. * @returns a parsed effect Layer
  56626. */
  56627. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56628. }
  56629. }
  56630. declare module BABYLON {
  56631. interface AbstractScene {
  56632. /**
  56633. * The list of effect layers (highlights/glow) added to the scene
  56634. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56635. * @see http://doc.babylonjs.com/how_to/glow_layer
  56636. */
  56637. effectLayers: Array<EffectLayer>;
  56638. /**
  56639. * Removes the given effect layer from this scene.
  56640. * @param toRemove defines the effect layer to remove
  56641. * @returns the index of the removed effect layer
  56642. */
  56643. removeEffectLayer(toRemove: EffectLayer): number;
  56644. /**
  56645. * Adds the given effect layer to this scene
  56646. * @param newEffectLayer defines the effect layer to add
  56647. */
  56648. addEffectLayer(newEffectLayer: EffectLayer): void;
  56649. }
  56650. /**
  56651. * Defines the layer scene component responsible to manage any effect layers
  56652. * in a given scene.
  56653. */
  56654. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56655. /**
  56656. * The component name helpfull to identify the component in the list of scene components.
  56657. */
  56658. readonly name: string;
  56659. /**
  56660. * The scene the component belongs to.
  56661. */
  56662. scene: Scene;
  56663. private _engine;
  56664. private _renderEffects;
  56665. private _needStencil;
  56666. private _previousStencilState;
  56667. /**
  56668. * Creates a new instance of the component for the given scene
  56669. * @param scene Defines the scene to register the component in
  56670. */
  56671. constructor(scene: Scene);
  56672. /**
  56673. * Registers the component in a given scene
  56674. */
  56675. register(): void;
  56676. /**
  56677. * Rebuilds the elements related to this component in case of
  56678. * context lost for instance.
  56679. */
  56680. rebuild(): void;
  56681. /**
  56682. * Serializes the component data to the specified json object
  56683. * @param serializationObject The object to serialize to
  56684. */
  56685. serialize(serializationObject: any): void;
  56686. /**
  56687. * Adds all the elements from the container to the scene
  56688. * @param container the container holding the elements
  56689. */
  56690. addFromContainer(container: AbstractScene): void;
  56691. /**
  56692. * Removes all the elements in the container from the scene
  56693. * @param container contains the elements to remove
  56694. * @param dispose if the removed element should be disposed (default: false)
  56695. */
  56696. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56697. /**
  56698. * Disposes the component and the associated ressources.
  56699. */
  56700. dispose(): void;
  56701. private _isReadyForMesh;
  56702. private _renderMainTexture;
  56703. private _setStencil;
  56704. private _setStencilBack;
  56705. private _draw;
  56706. private _drawCamera;
  56707. private _drawRenderingGroup;
  56708. }
  56709. }
  56710. declare module BABYLON {
  56711. /** @hidden */
  56712. export var glowMapMergePixelShader: {
  56713. name: string;
  56714. shader: string;
  56715. };
  56716. }
  56717. declare module BABYLON {
  56718. /** @hidden */
  56719. export var glowMapMergeVertexShader: {
  56720. name: string;
  56721. shader: string;
  56722. };
  56723. }
  56724. declare module BABYLON {
  56725. interface AbstractScene {
  56726. /**
  56727. * Return a the first highlight layer of the scene with a given name.
  56728. * @param name The name of the highlight layer to look for.
  56729. * @return The highlight layer if found otherwise null.
  56730. */
  56731. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56732. }
  56733. /**
  56734. * Glow layer options. This helps customizing the behaviour
  56735. * of the glow layer.
  56736. */
  56737. export interface IGlowLayerOptions {
  56738. /**
  56739. * Multiplication factor apply to the canvas size to compute the render target size
  56740. * used to generated the glowing objects (the smaller the faster).
  56741. */
  56742. mainTextureRatio: number;
  56743. /**
  56744. * Enforces a fixed size texture to ensure resize independant blur.
  56745. */
  56746. mainTextureFixedSize?: number;
  56747. /**
  56748. * How big is the kernel of the blur texture.
  56749. */
  56750. blurKernelSize: number;
  56751. /**
  56752. * The camera attached to the layer.
  56753. */
  56754. camera: Nullable<Camera>;
  56755. /**
  56756. * Enable MSAA by chosing the number of samples.
  56757. */
  56758. mainTextureSamples?: number;
  56759. /**
  56760. * The rendering group to draw the layer in.
  56761. */
  56762. renderingGroupId: number;
  56763. }
  56764. /**
  56765. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56766. *
  56767. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56768. *
  56769. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56770. */
  56771. export class GlowLayer extends EffectLayer {
  56772. /**
  56773. * Effect Name of the layer.
  56774. */
  56775. static readonly EffectName: string;
  56776. /**
  56777. * The default blur kernel size used for the glow.
  56778. */
  56779. static DefaultBlurKernelSize: number;
  56780. /**
  56781. * The default texture size ratio used for the glow.
  56782. */
  56783. static DefaultTextureRatio: number;
  56784. /**
  56785. * Sets the kernel size of the blur.
  56786. */
  56787. set blurKernelSize(value: number);
  56788. /**
  56789. * Gets the kernel size of the blur.
  56790. */
  56791. get blurKernelSize(): number;
  56792. /**
  56793. * Sets the glow intensity.
  56794. */
  56795. set intensity(value: number);
  56796. /**
  56797. * Gets the glow intensity.
  56798. */
  56799. get intensity(): number;
  56800. private _options;
  56801. private _intensity;
  56802. private _horizontalBlurPostprocess1;
  56803. private _verticalBlurPostprocess1;
  56804. private _horizontalBlurPostprocess2;
  56805. private _verticalBlurPostprocess2;
  56806. private _blurTexture1;
  56807. private _blurTexture2;
  56808. private _postProcesses1;
  56809. private _postProcesses2;
  56810. private _includedOnlyMeshes;
  56811. private _excludedMeshes;
  56812. private _meshesUsingTheirOwnMaterials;
  56813. /**
  56814. * Callback used to let the user override the color selection on a per mesh basis
  56815. */
  56816. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56817. /**
  56818. * Callback used to let the user override the texture selection on a per mesh basis
  56819. */
  56820. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56821. /**
  56822. * Instantiates a new glow Layer and references it to the scene.
  56823. * @param name The name of the layer
  56824. * @param scene The scene to use the layer in
  56825. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56826. */
  56827. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56828. /**
  56829. * Get the effect name of the layer.
  56830. * @return The effect name
  56831. */
  56832. getEffectName(): string;
  56833. /**
  56834. * Create the merge effect. This is the shader use to blit the information back
  56835. * to the main canvas at the end of the scene rendering.
  56836. */
  56837. protected _createMergeEffect(): Effect;
  56838. /**
  56839. * Creates the render target textures and post processes used in the glow layer.
  56840. */
  56841. protected _createTextureAndPostProcesses(): void;
  56842. /**
  56843. * Checks for the readiness of the element composing the layer.
  56844. * @param subMesh the mesh to check for
  56845. * @param useInstances specify wether or not to use instances to render the mesh
  56846. * @param emissiveTexture the associated emissive texture used to generate the glow
  56847. * @return true if ready otherwise, false
  56848. */
  56849. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56850. /**
  56851. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56852. */
  56853. needStencil(): boolean;
  56854. /**
  56855. * Returns true if the mesh can be rendered, otherwise false.
  56856. * @param mesh The mesh to render
  56857. * @param material The material used on the mesh
  56858. * @returns true if it can be rendered otherwise false
  56859. */
  56860. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56861. /**
  56862. * Implementation specific of rendering the generating effect on the main canvas.
  56863. * @param effect The effect used to render through
  56864. */
  56865. protected _internalRender(effect: Effect): void;
  56866. /**
  56867. * Sets the required values for both the emissive texture and and the main color.
  56868. */
  56869. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56870. /**
  56871. * Returns true if the mesh should render, otherwise false.
  56872. * @param mesh The mesh to render
  56873. * @returns true if it should render otherwise false
  56874. */
  56875. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56876. /**
  56877. * Adds specific effects defines.
  56878. * @param defines The defines to add specifics to.
  56879. */
  56880. protected _addCustomEffectDefines(defines: string[]): void;
  56881. /**
  56882. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56883. * @param mesh The mesh to exclude from the glow layer
  56884. */
  56885. addExcludedMesh(mesh: Mesh): void;
  56886. /**
  56887. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56888. * @param mesh The mesh to remove
  56889. */
  56890. removeExcludedMesh(mesh: Mesh): void;
  56891. /**
  56892. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56893. * @param mesh The mesh to include in the glow layer
  56894. */
  56895. addIncludedOnlyMesh(mesh: Mesh): void;
  56896. /**
  56897. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56898. * @param mesh The mesh to remove
  56899. */
  56900. removeIncludedOnlyMesh(mesh: Mesh): void;
  56901. /**
  56902. * Determine if a given mesh will be used in the glow layer
  56903. * @param mesh The mesh to test
  56904. * @returns true if the mesh will be highlighted by the current glow layer
  56905. */
  56906. hasMesh(mesh: AbstractMesh): boolean;
  56907. /**
  56908. * Defines whether the current material of the mesh should be use to render the effect.
  56909. * @param mesh defines the current mesh to render
  56910. */
  56911. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56912. /**
  56913. * Add a mesh to be rendered through its own material and not with emissive only.
  56914. * @param mesh The mesh for which we need to use its material
  56915. */
  56916. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56917. /**
  56918. * Remove a mesh from being rendered through its own material and not with emissive only.
  56919. * @param mesh The mesh for which we need to not use its material
  56920. */
  56921. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56922. /**
  56923. * Free any resources and references associated to a mesh.
  56924. * Internal use
  56925. * @param mesh The mesh to free.
  56926. * @hidden
  56927. */
  56928. _disposeMesh(mesh: Mesh): void;
  56929. /**
  56930. * Gets the class name of the effect layer
  56931. * @returns the string with the class name of the effect layer
  56932. */
  56933. getClassName(): string;
  56934. /**
  56935. * Serializes this glow layer
  56936. * @returns a serialized glow layer object
  56937. */
  56938. serialize(): any;
  56939. /**
  56940. * Creates a Glow Layer from parsed glow layer data
  56941. * @param parsedGlowLayer defines glow layer data
  56942. * @param scene defines the current scene
  56943. * @param rootUrl defines the root URL containing the glow layer information
  56944. * @returns a parsed Glow Layer
  56945. */
  56946. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56947. }
  56948. }
  56949. declare module BABYLON {
  56950. /** @hidden */
  56951. export var glowBlurPostProcessPixelShader: {
  56952. name: string;
  56953. shader: string;
  56954. };
  56955. }
  56956. declare module BABYLON {
  56957. interface AbstractScene {
  56958. /**
  56959. * Return a the first highlight layer of the scene with a given name.
  56960. * @param name The name of the highlight layer to look for.
  56961. * @return The highlight layer if found otherwise null.
  56962. */
  56963. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56964. }
  56965. /**
  56966. * Highlight layer options. This helps customizing the behaviour
  56967. * of the highlight layer.
  56968. */
  56969. export interface IHighlightLayerOptions {
  56970. /**
  56971. * Multiplication factor apply to the canvas size to compute the render target size
  56972. * used to generated the glowing objects (the smaller the faster).
  56973. */
  56974. mainTextureRatio: number;
  56975. /**
  56976. * Enforces a fixed size texture to ensure resize independant blur.
  56977. */
  56978. mainTextureFixedSize?: number;
  56979. /**
  56980. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56981. * of the picture to blur (the smaller the faster).
  56982. */
  56983. blurTextureSizeRatio: number;
  56984. /**
  56985. * How big in texel of the blur texture is the vertical blur.
  56986. */
  56987. blurVerticalSize: number;
  56988. /**
  56989. * How big in texel of the blur texture is the horizontal blur.
  56990. */
  56991. blurHorizontalSize: number;
  56992. /**
  56993. * Alpha blending mode used to apply the blur. Default is combine.
  56994. */
  56995. alphaBlendingMode: number;
  56996. /**
  56997. * The camera attached to the layer.
  56998. */
  56999. camera: Nullable<Camera>;
  57000. /**
  57001. * Should we display highlight as a solid stroke?
  57002. */
  57003. isStroke?: boolean;
  57004. /**
  57005. * The rendering group to draw the layer in.
  57006. */
  57007. renderingGroupId: number;
  57008. }
  57009. /**
  57010. * The highlight layer Helps adding a glow effect around a mesh.
  57011. *
  57012. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57013. * glowy meshes to your scene.
  57014. *
  57015. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57016. */
  57017. export class HighlightLayer extends EffectLayer {
  57018. name: string;
  57019. /**
  57020. * Effect Name of the highlight layer.
  57021. */
  57022. static readonly EffectName: string;
  57023. /**
  57024. * The neutral color used during the preparation of the glow effect.
  57025. * This is black by default as the blend operation is a blend operation.
  57026. */
  57027. static NeutralColor: Color4;
  57028. /**
  57029. * Stencil value used for glowing meshes.
  57030. */
  57031. static GlowingMeshStencilReference: number;
  57032. /**
  57033. * Stencil value used for the other meshes in the scene.
  57034. */
  57035. static NormalMeshStencilReference: number;
  57036. /**
  57037. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57038. */
  57039. innerGlow: boolean;
  57040. /**
  57041. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57042. */
  57043. outerGlow: boolean;
  57044. /**
  57045. * Specifies the horizontal size of the blur.
  57046. */
  57047. set blurHorizontalSize(value: number);
  57048. /**
  57049. * Specifies the vertical size of the blur.
  57050. */
  57051. set blurVerticalSize(value: number);
  57052. /**
  57053. * Gets the horizontal size of the blur.
  57054. */
  57055. get blurHorizontalSize(): number;
  57056. /**
  57057. * Gets the vertical size of the blur.
  57058. */
  57059. get blurVerticalSize(): number;
  57060. /**
  57061. * An event triggered when the highlight layer is being blurred.
  57062. */
  57063. onBeforeBlurObservable: Observable<HighlightLayer>;
  57064. /**
  57065. * An event triggered when the highlight layer has been blurred.
  57066. */
  57067. onAfterBlurObservable: Observable<HighlightLayer>;
  57068. private _instanceGlowingMeshStencilReference;
  57069. private _options;
  57070. private _downSamplePostprocess;
  57071. private _horizontalBlurPostprocess;
  57072. private _verticalBlurPostprocess;
  57073. private _blurTexture;
  57074. private _meshes;
  57075. private _excludedMeshes;
  57076. /**
  57077. * Instantiates a new highlight Layer and references it to the scene..
  57078. * @param name The name of the layer
  57079. * @param scene The scene to use the layer in
  57080. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57081. */
  57082. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57083. /**
  57084. * Get the effect name of the layer.
  57085. * @return The effect name
  57086. */
  57087. getEffectName(): string;
  57088. /**
  57089. * Create the merge effect. This is the shader use to blit the information back
  57090. * to the main canvas at the end of the scene rendering.
  57091. */
  57092. protected _createMergeEffect(): Effect;
  57093. /**
  57094. * Creates the render target textures and post processes used in the highlight layer.
  57095. */
  57096. protected _createTextureAndPostProcesses(): void;
  57097. /**
  57098. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57099. */
  57100. needStencil(): boolean;
  57101. /**
  57102. * Checks for the readiness of the element composing the layer.
  57103. * @param subMesh the mesh to check for
  57104. * @param useInstances specify wether or not to use instances to render the mesh
  57105. * @param emissiveTexture the associated emissive texture used to generate the glow
  57106. * @return true if ready otherwise, false
  57107. */
  57108. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57109. /**
  57110. * Implementation specific of rendering the generating effect on the main canvas.
  57111. * @param effect The effect used to render through
  57112. */
  57113. protected _internalRender(effect: Effect): void;
  57114. /**
  57115. * Returns true if the layer contains information to display, otherwise false.
  57116. */
  57117. shouldRender(): boolean;
  57118. /**
  57119. * Returns true if the mesh should render, otherwise false.
  57120. * @param mesh The mesh to render
  57121. * @returns true if it should render otherwise false
  57122. */
  57123. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57124. /**
  57125. * Adds specific effects defines.
  57126. * @param defines The defines to add specifics to.
  57127. */
  57128. protected _addCustomEffectDefines(defines: string[]): void;
  57129. /**
  57130. * Sets the required values for both the emissive texture and and the main color.
  57131. */
  57132. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57133. /**
  57134. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57135. * @param mesh The mesh to exclude from the highlight layer
  57136. */
  57137. addExcludedMesh(mesh: Mesh): void;
  57138. /**
  57139. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57140. * @param mesh The mesh to highlight
  57141. */
  57142. removeExcludedMesh(mesh: Mesh): void;
  57143. /**
  57144. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57145. * @param mesh mesh to test
  57146. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57147. */
  57148. hasMesh(mesh: AbstractMesh): boolean;
  57149. /**
  57150. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57151. * @param mesh The mesh to highlight
  57152. * @param color The color of the highlight
  57153. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57154. */
  57155. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57156. /**
  57157. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57158. * @param mesh The mesh to highlight
  57159. */
  57160. removeMesh(mesh: Mesh): void;
  57161. /**
  57162. * Remove all the meshes currently referenced in the highlight layer
  57163. */
  57164. removeAllMeshes(): void;
  57165. /**
  57166. * Force the stencil to the normal expected value for none glowing parts
  57167. */
  57168. private _defaultStencilReference;
  57169. /**
  57170. * Free any resources and references associated to a mesh.
  57171. * Internal use
  57172. * @param mesh The mesh to free.
  57173. * @hidden
  57174. */
  57175. _disposeMesh(mesh: Mesh): void;
  57176. /**
  57177. * Dispose the highlight layer and free resources.
  57178. */
  57179. dispose(): void;
  57180. /**
  57181. * Gets the class name of the effect layer
  57182. * @returns the string with the class name of the effect layer
  57183. */
  57184. getClassName(): string;
  57185. /**
  57186. * Serializes this Highlight layer
  57187. * @returns a serialized Highlight layer object
  57188. */
  57189. serialize(): any;
  57190. /**
  57191. * Creates a Highlight layer from parsed Highlight layer data
  57192. * @param parsedHightlightLayer defines the Highlight layer data
  57193. * @param scene defines the current scene
  57194. * @param rootUrl defines the root URL containing the Highlight layer information
  57195. * @returns a parsed Highlight layer
  57196. */
  57197. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57198. }
  57199. }
  57200. declare module BABYLON {
  57201. interface AbstractScene {
  57202. /**
  57203. * The list of layers (background and foreground) of the scene
  57204. */
  57205. layers: Array<Layer>;
  57206. }
  57207. /**
  57208. * Defines the layer scene component responsible to manage any layers
  57209. * in a given scene.
  57210. */
  57211. export class LayerSceneComponent implements ISceneComponent {
  57212. /**
  57213. * The component name helpfull to identify the component in the list of scene components.
  57214. */
  57215. readonly name: string;
  57216. /**
  57217. * The scene the component belongs to.
  57218. */
  57219. scene: Scene;
  57220. private _engine;
  57221. /**
  57222. * Creates a new instance of the component for the given scene
  57223. * @param scene Defines the scene to register the component in
  57224. */
  57225. constructor(scene: Scene);
  57226. /**
  57227. * Registers the component in a given scene
  57228. */
  57229. register(): void;
  57230. /**
  57231. * Rebuilds the elements related to this component in case of
  57232. * context lost for instance.
  57233. */
  57234. rebuild(): void;
  57235. /**
  57236. * Disposes the component and the associated ressources.
  57237. */
  57238. dispose(): void;
  57239. private _draw;
  57240. private _drawCameraPredicate;
  57241. private _drawCameraBackground;
  57242. private _drawCameraForeground;
  57243. private _drawRenderTargetPredicate;
  57244. private _drawRenderTargetBackground;
  57245. private _drawRenderTargetForeground;
  57246. /**
  57247. * Adds all the elements from the container to the scene
  57248. * @param container the container holding the elements
  57249. */
  57250. addFromContainer(container: AbstractScene): void;
  57251. /**
  57252. * Removes all the elements in the container from the scene
  57253. * @param container contains the elements to remove
  57254. * @param dispose if the removed element should be disposed (default: false)
  57255. */
  57256. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57257. }
  57258. }
  57259. declare module BABYLON {
  57260. /** @hidden */
  57261. export var layerPixelShader: {
  57262. name: string;
  57263. shader: string;
  57264. };
  57265. }
  57266. declare module BABYLON {
  57267. /** @hidden */
  57268. export var layerVertexShader: {
  57269. name: string;
  57270. shader: string;
  57271. };
  57272. }
  57273. declare module BABYLON {
  57274. /**
  57275. * This represents a full screen 2d layer.
  57276. * This can be useful to display a picture in the background of your scene for instance.
  57277. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57278. */
  57279. export class Layer {
  57280. /**
  57281. * Define the name of the layer.
  57282. */
  57283. name: string;
  57284. /**
  57285. * Define the texture the layer should display.
  57286. */
  57287. texture: Nullable<Texture>;
  57288. /**
  57289. * Is the layer in background or foreground.
  57290. */
  57291. isBackground: boolean;
  57292. /**
  57293. * Define the color of the layer (instead of texture).
  57294. */
  57295. color: Color4;
  57296. /**
  57297. * Define the scale of the layer in order to zoom in out of the texture.
  57298. */
  57299. scale: Vector2;
  57300. /**
  57301. * Define an offset for the layer in order to shift the texture.
  57302. */
  57303. offset: Vector2;
  57304. /**
  57305. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57306. */
  57307. alphaBlendingMode: number;
  57308. /**
  57309. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57310. * Alpha test will not mix with the background color in case of transparency.
  57311. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57312. */
  57313. alphaTest: boolean;
  57314. /**
  57315. * Define a mask to restrict the layer to only some of the scene cameras.
  57316. */
  57317. layerMask: number;
  57318. /**
  57319. * Define the list of render target the layer is visible into.
  57320. */
  57321. renderTargetTextures: RenderTargetTexture[];
  57322. /**
  57323. * Define if the layer is only used in renderTarget or if it also
  57324. * renders in the main frame buffer of the canvas.
  57325. */
  57326. renderOnlyInRenderTargetTextures: boolean;
  57327. private _scene;
  57328. private _vertexBuffers;
  57329. private _indexBuffer;
  57330. private _effect;
  57331. private _previousDefines;
  57332. /**
  57333. * An event triggered when the layer is disposed.
  57334. */
  57335. onDisposeObservable: Observable<Layer>;
  57336. private _onDisposeObserver;
  57337. /**
  57338. * Back compatibility with callback before the onDisposeObservable existed.
  57339. * The set callback will be triggered when the layer has been disposed.
  57340. */
  57341. set onDispose(callback: () => void);
  57342. /**
  57343. * An event triggered before rendering the scene
  57344. */
  57345. onBeforeRenderObservable: Observable<Layer>;
  57346. private _onBeforeRenderObserver;
  57347. /**
  57348. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57349. * The set callback will be triggered just before rendering the layer.
  57350. */
  57351. set onBeforeRender(callback: () => void);
  57352. /**
  57353. * An event triggered after rendering the scene
  57354. */
  57355. onAfterRenderObservable: Observable<Layer>;
  57356. private _onAfterRenderObserver;
  57357. /**
  57358. * Back compatibility with callback before the onAfterRenderObservable existed.
  57359. * The set callback will be triggered just after rendering the layer.
  57360. */
  57361. set onAfterRender(callback: () => void);
  57362. /**
  57363. * Instantiates a new layer.
  57364. * This represents a full screen 2d layer.
  57365. * This can be useful to display a picture in the background of your scene for instance.
  57366. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57367. * @param name Define the name of the layer in the scene
  57368. * @param imgUrl Define the url of the texture to display in the layer
  57369. * @param scene Define the scene the layer belongs to
  57370. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57371. * @param color Defines a color for the layer
  57372. */
  57373. constructor(
  57374. /**
  57375. * Define the name of the layer.
  57376. */
  57377. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57378. private _createIndexBuffer;
  57379. /** @hidden */
  57380. _rebuild(): void;
  57381. /**
  57382. * Renders the layer in the scene.
  57383. */
  57384. render(): void;
  57385. /**
  57386. * Disposes and releases the associated ressources.
  57387. */
  57388. dispose(): void;
  57389. }
  57390. }
  57391. declare module BABYLON {
  57392. /** @hidden */
  57393. export var lensFlarePixelShader: {
  57394. name: string;
  57395. shader: string;
  57396. };
  57397. }
  57398. declare module BABYLON {
  57399. /** @hidden */
  57400. export var lensFlareVertexShader: {
  57401. name: string;
  57402. shader: string;
  57403. };
  57404. }
  57405. declare module BABYLON {
  57406. /**
  57407. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57408. * It is usually composed of several `lensFlare`.
  57409. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57410. */
  57411. export class LensFlareSystem {
  57412. /**
  57413. * Define the name of the lens flare system
  57414. */
  57415. name: string;
  57416. /**
  57417. * List of lens flares used in this system.
  57418. */
  57419. lensFlares: LensFlare[];
  57420. /**
  57421. * Define a limit from the border the lens flare can be visible.
  57422. */
  57423. borderLimit: number;
  57424. /**
  57425. * Define a viewport border we do not want to see the lens flare in.
  57426. */
  57427. viewportBorder: number;
  57428. /**
  57429. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57430. */
  57431. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57432. /**
  57433. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57434. */
  57435. layerMask: number;
  57436. /**
  57437. * Define the id of the lens flare system in the scene.
  57438. * (equal to name by default)
  57439. */
  57440. id: string;
  57441. private _scene;
  57442. private _emitter;
  57443. private _vertexBuffers;
  57444. private _indexBuffer;
  57445. private _effect;
  57446. private _positionX;
  57447. private _positionY;
  57448. private _isEnabled;
  57449. /** @hidden */
  57450. static _SceneComponentInitialization: (scene: Scene) => void;
  57451. /**
  57452. * Instantiates a lens flare system.
  57453. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57454. * It is usually composed of several `lensFlare`.
  57455. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57456. * @param name Define the name of the lens flare system in the scene
  57457. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57458. * @param scene Define the scene the lens flare system belongs to
  57459. */
  57460. constructor(
  57461. /**
  57462. * Define the name of the lens flare system
  57463. */
  57464. name: string, emitter: any, scene: Scene);
  57465. /**
  57466. * Define if the lens flare system is enabled.
  57467. */
  57468. get isEnabled(): boolean;
  57469. set isEnabled(value: boolean);
  57470. /**
  57471. * Get the scene the effects belongs to.
  57472. * @returns the scene holding the lens flare system
  57473. */
  57474. getScene(): Scene;
  57475. /**
  57476. * Get the emitter of the lens flare system.
  57477. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57478. * @returns the emitter of the lens flare system
  57479. */
  57480. getEmitter(): any;
  57481. /**
  57482. * Set the emitter of the lens flare system.
  57483. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57484. * @param newEmitter Define the new emitter of the system
  57485. */
  57486. setEmitter(newEmitter: any): void;
  57487. /**
  57488. * Get the lens flare system emitter position.
  57489. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57490. * @returns the position
  57491. */
  57492. getEmitterPosition(): Vector3;
  57493. /**
  57494. * @hidden
  57495. */
  57496. computeEffectivePosition(globalViewport: Viewport): boolean;
  57497. /** @hidden */
  57498. _isVisible(): boolean;
  57499. /**
  57500. * @hidden
  57501. */
  57502. render(): boolean;
  57503. /**
  57504. * Dispose and release the lens flare with its associated resources.
  57505. */
  57506. dispose(): void;
  57507. /**
  57508. * Parse a lens flare system from a JSON repressentation
  57509. * @param parsedLensFlareSystem Define the JSON to parse
  57510. * @param scene Define the scene the parsed system should be instantiated in
  57511. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57512. * @returns the parsed system
  57513. */
  57514. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57515. /**
  57516. * Serialize the current Lens Flare System into a JSON representation.
  57517. * @returns the serialized JSON
  57518. */
  57519. serialize(): any;
  57520. }
  57521. }
  57522. declare module BABYLON {
  57523. /**
  57524. * This represents one of the lens effect in a `lensFlareSystem`.
  57525. * It controls one of the indiviual texture used in the effect.
  57526. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57527. */
  57528. export class LensFlare {
  57529. /**
  57530. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57531. */
  57532. size: number;
  57533. /**
  57534. * 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.
  57535. */
  57536. position: number;
  57537. /**
  57538. * Define the lens color.
  57539. */
  57540. color: Color3;
  57541. /**
  57542. * Define the lens texture.
  57543. */
  57544. texture: Nullable<Texture>;
  57545. /**
  57546. * Define the alpha mode to render this particular lens.
  57547. */
  57548. alphaMode: number;
  57549. private _system;
  57550. /**
  57551. * Creates a new Lens Flare.
  57552. * This represents one of the lens effect in a `lensFlareSystem`.
  57553. * It controls one of the indiviual texture used in the effect.
  57554. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57555. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57556. * @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.
  57557. * @param color Define the lens color
  57558. * @param imgUrl Define the lens texture url
  57559. * @param system Define the `lensFlareSystem` this flare is part of
  57560. * @returns The newly created Lens Flare
  57561. */
  57562. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57563. /**
  57564. * Instantiates a new Lens Flare.
  57565. * This represents one of the lens effect in a `lensFlareSystem`.
  57566. * It controls one of the indiviual texture used in the effect.
  57567. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57568. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57569. * @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.
  57570. * @param color Define the lens color
  57571. * @param imgUrl Define the lens texture url
  57572. * @param system Define the `lensFlareSystem` this flare is part of
  57573. */
  57574. constructor(
  57575. /**
  57576. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57577. */
  57578. size: number,
  57579. /**
  57580. * 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.
  57581. */
  57582. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57583. /**
  57584. * Dispose and release the lens flare with its associated resources.
  57585. */
  57586. dispose(): void;
  57587. }
  57588. }
  57589. declare module BABYLON {
  57590. interface AbstractScene {
  57591. /**
  57592. * The list of lens flare system added to the scene
  57593. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57594. */
  57595. lensFlareSystems: Array<LensFlareSystem>;
  57596. /**
  57597. * Removes the given lens flare system from this scene.
  57598. * @param toRemove The lens flare system to remove
  57599. * @returns The index of the removed lens flare system
  57600. */
  57601. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57602. /**
  57603. * Adds the given lens flare system to this scene
  57604. * @param newLensFlareSystem The lens flare system to add
  57605. */
  57606. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57607. /**
  57608. * Gets a lens flare system using its name
  57609. * @param name defines the name to look for
  57610. * @returns the lens flare system or null if not found
  57611. */
  57612. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57613. /**
  57614. * Gets a lens flare system using its id
  57615. * @param id defines the id to look for
  57616. * @returns the lens flare system or null if not found
  57617. */
  57618. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57619. }
  57620. /**
  57621. * Defines the lens flare scene component responsible to manage any lens flares
  57622. * in a given scene.
  57623. */
  57624. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57625. /**
  57626. * The component name helpfull to identify the component in the list of scene components.
  57627. */
  57628. readonly name: string;
  57629. /**
  57630. * The scene the component belongs to.
  57631. */
  57632. scene: Scene;
  57633. /**
  57634. * Creates a new instance of the component for the given scene
  57635. * @param scene Defines the scene to register the component in
  57636. */
  57637. constructor(scene: Scene);
  57638. /**
  57639. * Registers the component in a given scene
  57640. */
  57641. register(): void;
  57642. /**
  57643. * Rebuilds the elements related to this component in case of
  57644. * context lost for instance.
  57645. */
  57646. rebuild(): void;
  57647. /**
  57648. * Adds all the elements from the container to the scene
  57649. * @param container the container holding the elements
  57650. */
  57651. addFromContainer(container: AbstractScene): void;
  57652. /**
  57653. * Removes all the elements in the container from the scene
  57654. * @param container contains the elements to remove
  57655. * @param dispose if the removed element should be disposed (default: false)
  57656. */
  57657. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57658. /**
  57659. * Serializes the component data to the specified json object
  57660. * @param serializationObject The object to serialize to
  57661. */
  57662. serialize(serializationObject: any): void;
  57663. /**
  57664. * Disposes the component and the associated ressources.
  57665. */
  57666. dispose(): void;
  57667. private _draw;
  57668. }
  57669. }
  57670. declare module BABYLON {
  57671. /** @hidden */
  57672. export var depthPixelShader: {
  57673. name: string;
  57674. shader: string;
  57675. };
  57676. }
  57677. declare module BABYLON {
  57678. /** @hidden */
  57679. export var depthVertexShader: {
  57680. name: string;
  57681. shader: string;
  57682. };
  57683. }
  57684. declare module BABYLON {
  57685. /**
  57686. * This represents a depth renderer in Babylon.
  57687. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57688. */
  57689. export class DepthRenderer {
  57690. private _scene;
  57691. private _depthMap;
  57692. private _effect;
  57693. private readonly _storeNonLinearDepth;
  57694. private readonly _clearColor;
  57695. /** Get if the depth renderer is using packed depth or not */
  57696. readonly isPacked: boolean;
  57697. private _cachedDefines;
  57698. private _camera;
  57699. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57700. enabled: boolean;
  57701. /**
  57702. * Specifiess that the depth renderer will only be used within
  57703. * the camera it is created for.
  57704. * This can help forcing its rendering during the camera processing.
  57705. */
  57706. useOnlyInActiveCamera: boolean;
  57707. /** @hidden */
  57708. static _SceneComponentInitialization: (scene: Scene) => void;
  57709. /**
  57710. * Instantiates a depth renderer
  57711. * @param scene The scene the renderer belongs to
  57712. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57713. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57714. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57715. */
  57716. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57717. /**
  57718. * Creates the depth rendering effect and checks if the effect is ready.
  57719. * @param subMesh The submesh to be used to render the depth map of
  57720. * @param useInstances If multiple world instances should be used
  57721. * @returns if the depth renderer is ready to render the depth map
  57722. */
  57723. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57724. /**
  57725. * Gets the texture which the depth map will be written to.
  57726. * @returns The depth map texture
  57727. */
  57728. getDepthMap(): RenderTargetTexture;
  57729. /**
  57730. * Disposes of the depth renderer.
  57731. */
  57732. dispose(): void;
  57733. }
  57734. }
  57735. declare module BABYLON {
  57736. /** @hidden */
  57737. export var minmaxReduxPixelShader: {
  57738. name: string;
  57739. shader: string;
  57740. };
  57741. }
  57742. declare module BABYLON {
  57743. /**
  57744. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57745. * and maximum values from all values of the texture.
  57746. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57747. * The source values are read from the red channel of the texture.
  57748. */
  57749. export class MinMaxReducer {
  57750. /**
  57751. * Observable triggered when the computation has been performed
  57752. */
  57753. onAfterReductionPerformed: Observable<{
  57754. min: number;
  57755. max: number;
  57756. }>;
  57757. protected _camera: Camera;
  57758. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57759. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57760. protected _postProcessManager: PostProcessManager;
  57761. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57762. protected _forceFullscreenViewport: boolean;
  57763. /**
  57764. * Creates a min/max reducer
  57765. * @param camera The camera to use for the post processes
  57766. */
  57767. constructor(camera: Camera);
  57768. /**
  57769. * Gets the texture used to read the values from.
  57770. */
  57771. get sourceTexture(): Nullable<RenderTargetTexture>;
  57772. /**
  57773. * Sets the source texture to read the values from.
  57774. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57775. * because in such textures '1' value must not be taken into account to compute the maximum
  57776. * as this value is used to clear the texture.
  57777. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57778. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57779. * @param depthRedux Indicates if the texture is a depth texture or not
  57780. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57781. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57782. */
  57783. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57784. /**
  57785. * Defines the refresh rate of the computation.
  57786. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57787. */
  57788. get refreshRate(): number;
  57789. set refreshRate(value: number);
  57790. protected _activated: boolean;
  57791. /**
  57792. * Gets the activation status of the reducer
  57793. */
  57794. get activated(): boolean;
  57795. /**
  57796. * Activates the reduction computation.
  57797. * When activated, the observers registered in onAfterReductionPerformed are
  57798. * called after the compuation is performed
  57799. */
  57800. activate(): void;
  57801. /**
  57802. * Deactivates the reduction computation.
  57803. */
  57804. deactivate(): void;
  57805. /**
  57806. * Disposes the min/max reducer
  57807. * @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.
  57808. */
  57809. dispose(disposeAll?: boolean): void;
  57810. }
  57811. }
  57812. declare module BABYLON {
  57813. /**
  57814. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57815. */
  57816. export class DepthReducer extends MinMaxReducer {
  57817. private _depthRenderer;
  57818. private _depthRendererId;
  57819. /**
  57820. * Gets the depth renderer used for the computation.
  57821. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57822. */
  57823. get depthRenderer(): Nullable<DepthRenderer>;
  57824. /**
  57825. * Creates a depth reducer
  57826. * @param camera The camera used to render the depth texture
  57827. */
  57828. constructor(camera: Camera);
  57829. /**
  57830. * Sets the depth renderer to use to generate the depth map
  57831. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57832. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57833. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57834. */
  57835. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57836. /** @hidden */
  57837. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57838. /**
  57839. * Activates the reduction computation.
  57840. * When activated, the observers registered in onAfterReductionPerformed are
  57841. * called after the compuation is performed
  57842. */
  57843. activate(): void;
  57844. /**
  57845. * Deactivates the reduction computation.
  57846. */
  57847. deactivate(): void;
  57848. /**
  57849. * Disposes the depth reducer
  57850. * @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.
  57851. */
  57852. dispose(disposeAll?: boolean): void;
  57853. }
  57854. }
  57855. declare module BABYLON {
  57856. /**
  57857. * A CSM implementation allowing casting shadows on large scenes.
  57858. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57859. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57860. */
  57861. export class CascadedShadowGenerator extends ShadowGenerator {
  57862. private static readonly frustumCornersNDCSpace;
  57863. /**
  57864. * Name of the CSM class
  57865. */
  57866. static CLASSNAME: string;
  57867. /**
  57868. * Defines the default number of cascades used by the CSM.
  57869. */
  57870. static readonly DEFAULT_CASCADES_COUNT: number;
  57871. /**
  57872. * Defines the minimum number of cascades used by the CSM.
  57873. */
  57874. static readonly MIN_CASCADES_COUNT: number;
  57875. /**
  57876. * Defines the maximum number of cascades used by the CSM.
  57877. */
  57878. static readonly MAX_CASCADES_COUNT: number;
  57879. protected _validateFilter(filter: number): number;
  57880. /**
  57881. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57882. */
  57883. penumbraDarkness: number;
  57884. private _numCascades;
  57885. /**
  57886. * Gets or set the number of cascades used by the CSM.
  57887. */
  57888. get numCascades(): number;
  57889. set numCascades(value: number);
  57890. /**
  57891. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57892. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  57893. */
  57894. stabilizeCascades: boolean;
  57895. private _freezeShadowCastersBoundingInfo;
  57896. private _freezeShadowCastersBoundingInfoObservable;
  57897. /**
  57898. * Enables or disables the shadow casters bounding info computation.
  57899. * If your shadow casters don't move, you can disable this feature.
  57900. * If it is enabled, the bounding box computation is done every frame.
  57901. */
  57902. get freezeShadowCastersBoundingInfo(): boolean;
  57903. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57904. private _scbiMin;
  57905. private _scbiMax;
  57906. protected _computeShadowCastersBoundingInfo(): void;
  57907. protected _shadowCastersBoundingInfo: BoundingInfo;
  57908. /**
  57909. * Gets or sets the shadow casters bounding info.
  57910. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57911. * so that the system won't overwrite the bounds you provide
  57912. */
  57913. get shadowCastersBoundingInfo(): BoundingInfo;
  57914. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57915. protected _breaksAreDirty: boolean;
  57916. protected _minDistance: number;
  57917. protected _maxDistance: number;
  57918. /**
  57919. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57920. *
  57921. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57922. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57923. * @param min minimal distance for the breaks (default to 0.)
  57924. * @param max maximal distance for the breaks (default to 1.)
  57925. */
  57926. setMinMaxDistance(min: number, max: number): void;
  57927. /** Gets the minimal distance used in the cascade break computation */
  57928. get minDistance(): number;
  57929. /** Gets the maximal distance used in the cascade break computation */
  57930. get maxDistance(): number;
  57931. /**
  57932. * Gets the class name of that object
  57933. * @returns "CascadedShadowGenerator"
  57934. */
  57935. getClassName(): string;
  57936. private _cascadeMinExtents;
  57937. private _cascadeMaxExtents;
  57938. /**
  57939. * Gets a cascade minimum extents
  57940. * @param cascadeIndex index of the cascade
  57941. * @returns the minimum cascade extents
  57942. */
  57943. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57944. /**
  57945. * Gets a cascade maximum extents
  57946. * @param cascadeIndex index of the cascade
  57947. * @returns the maximum cascade extents
  57948. */
  57949. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57950. private _cascades;
  57951. private _currentLayer;
  57952. private _viewSpaceFrustumsZ;
  57953. private _viewMatrices;
  57954. private _projectionMatrices;
  57955. private _transformMatrices;
  57956. private _transformMatricesAsArray;
  57957. private _frustumLengths;
  57958. private _lightSizeUVCorrection;
  57959. private _depthCorrection;
  57960. private _frustumCornersWorldSpace;
  57961. private _frustumCenter;
  57962. private _shadowCameraPos;
  57963. private _shadowMaxZ;
  57964. /**
  57965. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57966. * It defaults to camera.maxZ
  57967. */
  57968. get shadowMaxZ(): number;
  57969. /**
  57970. * Sets the shadow max z distance.
  57971. */
  57972. set shadowMaxZ(value: number);
  57973. protected _debug: boolean;
  57974. /**
  57975. * Gets or sets the debug flag.
  57976. * When enabled, the cascades are materialized by different colors on the screen.
  57977. */
  57978. get debug(): boolean;
  57979. set debug(dbg: boolean);
  57980. private _depthClamp;
  57981. /**
  57982. * Gets or sets the depth clamping value.
  57983. *
  57984. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57985. * to account for the shadow casters far away.
  57986. *
  57987. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57988. */
  57989. get depthClamp(): boolean;
  57990. set depthClamp(value: boolean);
  57991. private _cascadeBlendPercentage;
  57992. /**
  57993. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57994. * It defaults to 0.1 (10% blending).
  57995. */
  57996. get cascadeBlendPercentage(): number;
  57997. set cascadeBlendPercentage(value: number);
  57998. private _lambda;
  57999. /**
  58000. * Gets or set the lambda parameter.
  58001. * This parameter is used to split the camera frustum and create the cascades.
  58002. * 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.
  58003. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58004. */
  58005. get lambda(): number;
  58006. set lambda(value: number);
  58007. /**
  58008. * Gets the view matrix corresponding to a given cascade
  58009. * @param cascadeNum cascade to retrieve the view matrix from
  58010. * @returns the cascade view matrix
  58011. */
  58012. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58013. /**
  58014. * Gets the projection matrix corresponding to a given cascade
  58015. * @param cascadeNum cascade to retrieve the projection matrix from
  58016. * @returns the cascade projection matrix
  58017. */
  58018. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58019. /**
  58020. * Gets the transformation matrix corresponding to a given cascade
  58021. * @param cascadeNum cascade to retrieve the transformation matrix from
  58022. * @returns the cascade transformation matrix
  58023. */
  58024. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58025. private _depthRenderer;
  58026. /**
  58027. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58028. *
  58029. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58030. *
  58031. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58032. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58033. * @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
  58034. */
  58035. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58036. private _depthReducer;
  58037. private _autoCalcDepthBounds;
  58038. /**
  58039. * Gets or sets the autoCalcDepthBounds property.
  58040. *
  58041. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58042. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58043. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58044. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58045. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58046. */
  58047. get autoCalcDepthBounds(): boolean;
  58048. set autoCalcDepthBounds(value: boolean);
  58049. /**
  58050. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58051. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58052. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58053. * for setting the refresh rate on the renderer yourself!
  58054. */
  58055. get autoCalcDepthBoundsRefreshRate(): number;
  58056. set autoCalcDepthBoundsRefreshRate(value: number);
  58057. /**
  58058. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58059. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58060. * you change the camera near/far planes!
  58061. */
  58062. splitFrustum(): void;
  58063. private _splitFrustum;
  58064. private _computeMatrices;
  58065. private _computeFrustumInWorldSpace;
  58066. private _computeCascadeFrustum;
  58067. /**
  58068. * Support test.
  58069. */
  58070. static get IsSupported(): boolean;
  58071. /** @hidden */
  58072. static _SceneComponentInitialization: (scene: Scene) => void;
  58073. /**
  58074. * Creates a Cascaded Shadow Generator object.
  58075. * A ShadowGenerator is the required tool to use the shadows.
  58076. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58077. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58078. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58079. * @param light The directional light object generating the shadows.
  58080. * @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.
  58081. */
  58082. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58083. protected _initializeGenerator(): void;
  58084. protected _createTargetRenderTexture(): void;
  58085. protected _initializeShadowMap(): void;
  58086. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58087. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58088. /**
  58089. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58090. * @param defines Defines of the material we want to update
  58091. * @param lightIndex Index of the light in the enabled light list of the material
  58092. */
  58093. prepareDefines(defines: any, lightIndex: number): void;
  58094. /**
  58095. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58096. * defined in the generator but impacting the effect).
  58097. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58098. * @param effect The effect we are binfing the information for
  58099. */
  58100. bindShadowLight(lightIndex: string, effect: Effect): void;
  58101. /**
  58102. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58103. * (eq to view projection * shadow projection matrices)
  58104. * @returns The transform matrix used to create the shadow map
  58105. */
  58106. getTransformMatrix(): Matrix;
  58107. /**
  58108. * Disposes the ShadowGenerator.
  58109. * Returns nothing.
  58110. */
  58111. dispose(): void;
  58112. /**
  58113. * Serializes the shadow generator setup to a json object.
  58114. * @returns The serialized JSON object
  58115. */
  58116. serialize(): any;
  58117. /**
  58118. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58119. * @param parsedShadowGenerator The JSON object to parse
  58120. * @param scene The scene to create the shadow map for
  58121. * @returns The parsed shadow generator
  58122. */
  58123. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58124. }
  58125. }
  58126. declare module BABYLON {
  58127. /**
  58128. * Defines the shadow generator component responsible to manage any shadow generators
  58129. * in a given scene.
  58130. */
  58131. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58132. /**
  58133. * The component name helpfull to identify the component in the list of scene components.
  58134. */
  58135. readonly name: string;
  58136. /**
  58137. * The scene the component belongs to.
  58138. */
  58139. scene: Scene;
  58140. /**
  58141. * Creates a new instance of the component for the given scene
  58142. * @param scene Defines the scene to register the component in
  58143. */
  58144. constructor(scene: Scene);
  58145. /**
  58146. * Registers the component in a given scene
  58147. */
  58148. register(): void;
  58149. /**
  58150. * Rebuilds the elements related to this component in case of
  58151. * context lost for instance.
  58152. */
  58153. rebuild(): void;
  58154. /**
  58155. * Serializes the component data to the specified json object
  58156. * @param serializationObject The object to serialize to
  58157. */
  58158. serialize(serializationObject: any): void;
  58159. /**
  58160. * Adds all the elements from the container to the scene
  58161. * @param container the container holding the elements
  58162. */
  58163. addFromContainer(container: AbstractScene): void;
  58164. /**
  58165. * Removes all the elements in the container from the scene
  58166. * @param container contains the elements to remove
  58167. * @param dispose if the removed element should be disposed (default: false)
  58168. */
  58169. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58170. /**
  58171. * Rebuilds the elements related to this component in case of
  58172. * context lost for instance.
  58173. */
  58174. dispose(): void;
  58175. private _gatherRenderTargets;
  58176. }
  58177. }
  58178. declare module BABYLON {
  58179. /**
  58180. * A point light is a light defined by an unique point in world space.
  58181. * The light is emitted in every direction from this point.
  58182. * A good example of a point light is a standard light bulb.
  58183. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58184. */
  58185. export class PointLight extends ShadowLight {
  58186. private _shadowAngle;
  58187. /**
  58188. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58189. * This specifies what angle the shadow will use to be created.
  58190. *
  58191. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58192. */
  58193. get shadowAngle(): number;
  58194. /**
  58195. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58196. * This specifies what angle the shadow will use to be created.
  58197. *
  58198. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58199. */
  58200. set shadowAngle(value: number);
  58201. /**
  58202. * Gets the direction if it has been set.
  58203. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58204. */
  58205. get direction(): Vector3;
  58206. /**
  58207. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58208. */
  58209. set direction(value: Vector3);
  58210. /**
  58211. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58212. * A PointLight emits the light in every direction.
  58213. * It can cast shadows.
  58214. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58215. * ```javascript
  58216. * var pointLight = new PointLight("pl", camera.position, scene);
  58217. * ```
  58218. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58219. * @param name The light friendly name
  58220. * @param position The position of the point light in the scene
  58221. * @param scene The scene the lights belongs to
  58222. */
  58223. constructor(name: string, position: Vector3, scene: Scene);
  58224. /**
  58225. * Returns the string "PointLight"
  58226. * @returns the class name
  58227. */
  58228. getClassName(): string;
  58229. /**
  58230. * Returns the integer 0.
  58231. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58232. */
  58233. getTypeID(): number;
  58234. /**
  58235. * Specifies wether or not the shadowmap should be a cube texture.
  58236. * @returns true if the shadowmap needs to be a cube texture.
  58237. */
  58238. needCube(): boolean;
  58239. /**
  58240. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58241. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58242. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58243. */
  58244. getShadowDirection(faceIndex?: number): Vector3;
  58245. /**
  58246. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58247. * - fov = PI / 2
  58248. * - aspect ratio : 1.0
  58249. * - z-near and far equal to the active camera minZ and maxZ.
  58250. * Returns the PointLight.
  58251. */
  58252. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58253. protected _buildUniformLayout(): void;
  58254. /**
  58255. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58256. * @param effect The effect to update
  58257. * @param lightIndex The index of the light in the effect to update
  58258. * @returns The point light
  58259. */
  58260. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58261. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58262. /**
  58263. * Prepares the list of defines specific to the light type.
  58264. * @param defines the list of defines
  58265. * @param lightIndex defines the index of the light for the effect
  58266. */
  58267. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58268. }
  58269. }
  58270. declare module BABYLON {
  58271. /**
  58272. * Header information of HDR texture files.
  58273. */
  58274. export interface HDRInfo {
  58275. /**
  58276. * The height of the texture in pixels.
  58277. */
  58278. height: number;
  58279. /**
  58280. * The width of the texture in pixels.
  58281. */
  58282. width: number;
  58283. /**
  58284. * The index of the beginning of the data in the binary file.
  58285. */
  58286. dataPosition: number;
  58287. }
  58288. /**
  58289. * This groups tools to convert HDR texture to native colors array.
  58290. */
  58291. export class HDRTools {
  58292. private static Ldexp;
  58293. private static Rgbe2float;
  58294. private static readStringLine;
  58295. /**
  58296. * Reads header information from an RGBE texture stored in a native array.
  58297. * More information on this format are available here:
  58298. * https://en.wikipedia.org/wiki/RGBE_image_format
  58299. *
  58300. * @param uint8array The binary file stored in native array.
  58301. * @return The header information.
  58302. */
  58303. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58304. /**
  58305. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58306. * This RGBE texture needs to store the information as a panorama.
  58307. *
  58308. * More information on this format are available here:
  58309. * https://en.wikipedia.org/wiki/RGBE_image_format
  58310. *
  58311. * @param buffer The binary file stored in an array buffer.
  58312. * @param size The expected size of the extracted cubemap.
  58313. * @return The Cube Map information.
  58314. */
  58315. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58316. /**
  58317. * Returns the pixels data extracted from an RGBE texture.
  58318. * This pixels will be stored left to right up to down in the R G B order in one array.
  58319. *
  58320. * More information on this format are available here:
  58321. * https://en.wikipedia.org/wiki/RGBE_image_format
  58322. *
  58323. * @param uint8array The binary file stored in an array buffer.
  58324. * @param hdrInfo The header information of the file.
  58325. * @return The pixels data in RGB right to left up to down order.
  58326. */
  58327. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58328. private static RGBE_ReadPixels_RLE;
  58329. }
  58330. }
  58331. declare module BABYLON {
  58332. /**
  58333. * Effect Render Options
  58334. */
  58335. export interface IEffectRendererOptions {
  58336. /**
  58337. * Defines the vertices positions.
  58338. */
  58339. positions?: number[];
  58340. /**
  58341. * Defines the indices.
  58342. */
  58343. indices?: number[];
  58344. }
  58345. /**
  58346. * Helper class to render one or more effects.
  58347. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58348. */
  58349. export class EffectRenderer {
  58350. private engine;
  58351. private static _DefaultOptions;
  58352. private _vertexBuffers;
  58353. private _indexBuffer;
  58354. private _fullscreenViewport;
  58355. /**
  58356. * Creates an effect renderer
  58357. * @param engine the engine to use for rendering
  58358. * @param options defines the options of the effect renderer
  58359. */
  58360. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58361. /**
  58362. * Sets the current viewport in normalized coordinates 0-1
  58363. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58364. */
  58365. setViewport(viewport?: Viewport): void;
  58366. /**
  58367. * Binds the embedded attributes buffer to the effect.
  58368. * @param effect Defines the effect to bind the attributes for
  58369. */
  58370. bindBuffers(effect: Effect): void;
  58371. /**
  58372. * Sets the current effect wrapper to use during draw.
  58373. * The effect needs to be ready before calling this api.
  58374. * This also sets the default full screen position attribute.
  58375. * @param effectWrapper Defines the effect to draw with
  58376. */
  58377. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58378. /**
  58379. * Restores engine states
  58380. */
  58381. restoreStates(): void;
  58382. /**
  58383. * Draws a full screen quad.
  58384. */
  58385. draw(): void;
  58386. private isRenderTargetTexture;
  58387. /**
  58388. * renders one or more effects to a specified texture
  58389. * @param effectWrapper the effect to renderer
  58390. * @param outputTexture texture to draw to, if null it will render to the screen.
  58391. */
  58392. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58393. /**
  58394. * Disposes of the effect renderer
  58395. */
  58396. dispose(): void;
  58397. }
  58398. /**
  58399. * Options to create an EffectWrapper
  58400. */
  58401. interface EffectWrapperCreationOptions {
  58402. /**
  58403. * Engine to use to create the effect
  58404. */
  58405. engine: ThinEngine;
  58406. /**
  58407. * Fragment shader for the effect
  58408. */
  58409. fragmentShader: string;
  58410. /**
  58411. * Use the shader store instead of direct source code
  58412. */
  58413. useShaderStore?: boolean;
  58414. /**
  58415. * Vertex shader for the effect
  58416. */
  58417. vertexShader?: string;
  58418. /**
  58419. * Attributes to use in the shader
  58420. */
  58421. attributeNames?: Array<string>;
  58422. /**
  58423. * Uniforms to use in the shader
  58424. */
  58425. uniformNames?: Array<string>;
  58426. /**
  58427. * Texture sampler names to use in the shader
  58428. */
  58429. samplerNames?: Array<string>;
  58430. /**
  58431. * Defines to use in the shader
  58432. */
  58433. defines?: Array<string>;
  58434. /**
  58435. * Callback when effect is compiled
  58436. */
  58437. onCompiled?: Nullable<(effect: Effect) => void>;
  58438. /**
  58439. * The friendly name of the effect displayed in Spector.
  58440. */
  58441. name?: string;
  58442. }
  58443. /**
  58444. * Wraps an effect to be used for rendering
  58445. */
  58446. export class EffectWrapper {
  58447. /**
  58448. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58449. */
  58450. onApplyObservable: Observable<{}>;
  58451. /**
  58452. * The underlying effect
  58453. */
  58454. effect: Effect;
  58455. /**
  58456. * Creates an effect to be renderer
  58457. * @param creationOptions options to create the effect
  58458. */
  58459. constructor(creationOptions: EffectWrapperCreationOptions);
  58460. /**
  58461. * Disposes of the effect wrapper
  58462. */
  58463. dispose(): void;
  58464. }
  58465. }
  58466. declare module BABYLON {
  58467. /** @hidden */
  58468. export var hdrFilteringVertexShader: {
  58469. name: string;
  58470. shader: string;
  58471. };
  58472. }
  58473. declare module BABYLON {
  58474. /** @hidden */
  58475. export var hdrFilteringPixelShader: {
  58476. name: string;
  58477. shader: string;
  58478. };
  58479. }
  58480. declare module BABYLON {
  58481. /**
  58482. * Options for texture filtering
  58483. */
  58484. interface IHDRFilteringOptions {
  58485. /**
  58486. * Scales pixel intensity for the input HDR map.
  58487. */
  58488. hdrScale?: number;
  58489. /**
  58490. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58491. */
  58492. quality?: number;
  58493. }
  58494. /**
  58495. * Filters HDR maps to get correct renderings of PBR reflections
  58496. */
  58497. export class HDRFiltering {
  58498. private _engine;
  58499. private _effectRenderer;
  58500. private _effectWrapper;
  58501. private _lodGenerationOffset;
  58502. private _lodGenerationScale;
  58503. /**
  58504. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58505. * you care about baking speed.
  58506. */
  58507. quality: number;
  58508. /**
  58509. * Scales pixel intensity for the input HDR map.
  58510. */
  58511. hdrScale: number;
  58512. /**
  58513. * Instantiates HDR filter for reflection maps
  58514. *
  58515. * @param engine Thin engine
  58516. * @param options Options
  58517. */
  58518. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58519. private _createRenderTarget;
  58520. private _prefilterInternal;
  58521. private _createEffect;
  58522. /**
  58523. * Get a value indicating if the filter is ready to be used
  58524. * @param texture Texture to filter
  58525. * @returns true if the filter is ready
  58526. */
  58527. isReady(texture: BaseTexture): boolean;
  58528. /**
  58529. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58530. * Prefiltering will be invoked at the end of next rendering pass.
  58531. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58532. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58533. * @param texture Texture to filter
  58534. * @param onFinished Callback when filtering is done
  58535. * @return Promise called when prefiltering is done
  58536. */
  58537. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  58538. }
  58539. }
  58540. declare module BABYLON {
  58541. /**
  58542. * This represents a texture coming from an HDR input.
  58543. *
  58544. * The only supported format is currently panorama picture stored in RGBE format.
  58545. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58546. */
  58547. export class HDRCubeTexture extends BaseTexture {
  58548. private static _facesMapping;
  58549. private _generateHarmonics;
  58550. private _noMipmap;
  58551. private _prefilterOnLoad;
  58552. private _textureMatrix;
  58553. private _size;
  58554. private _onLoad;
  58555. private _onError;
  58556. /**
  58557. * The texture URL.
  58558. */
  58559. url: string;
  58560. /**
  58561. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58562. */
  58563. coordinatesMode: number;
  58564. protected _isBlocking: boolean;
  58565. /**
  58566. * Sets wether or not the texture is blocking during loading.
  58567. */
  58568. set isBlocking(value: boolean);
  58569. /**
  58570. * Gets wether or not the texture is blocking during loading.
  58571. */
  58572. get isBlocking(): boolean;
  58573. protected _rotationY: number;
  58574. /**
  58575. * Sets texture matrix rotation angle around Y axis in radians.
  58576. */
  58577. set rotationY(value: number);
  58578. /**
  58579. * Gets texture matrix rotation angle around Y axis radians.
  58580. */
  58581. get rotationY(): number;
  58582. /**
  58583. * Gets or sets the center of the bounding box associated with the cube texture
  58584. * It must define where the camera used to render the texture was set
  58585. */
  58586. boundingBoxPosition: Vector3;
  58587. private _boundingBoxSize;
  58588. /**
  58589. * Gets or sets the size of the bounding box associated with the cube texture
  58590. * When defined, the cubemap will switch to local mode
  58591. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58592. * @example https://www.babylonjs-playground.com/#RNASML
  58593. */
  58594. set boundingBoxSize(value: Vector3);
  58595. get boundingBoxSize(): Vector3;
  58596. /**
  58597. * Instantiates an HDRTexture from the following parameters.
  58598. *
  58599. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58600. * @param sceneOrEngine The scene or engine the texture will be used in
  58601. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58602. * @param noMipmap Forces to not generate the mipmap if true
  58603. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58604. * @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)
  58605. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  58606. */
  58607. 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>);
  58608. /**
  58609. * Get the current class name of the texture useful for serialization or dynamic coding.
  58610. * @returns "HDRCubeTexture"
  58611. */
  58612. getClassName(): string;
  58613. /**
  58614. * Occurs when the file is raw .hdr file.
  58615. */
  58616. private loadTexture;
  58617. clone(): HDRCubeTexture;
  58618. delayLoad(): void;
  58619. /**
  58620. * Get the texture reflection matrix used to rotate/transform the reflection.
  58621. * @returns the reflection matrix
  58622. */
  58623. getReflectionTextureMatrix(): Matrix;
  58624. /**
  58625. * Set the texture reflection matrix used to rotate/transform the reflection.
  58626. * @param value Define the reflection matrix to set
  58627. */
  58628. setReflectionTextureMatrix(value: Matrix): void;
  58629. /**
  58630. * Parses a JSON representation of an HDR Texture in order to create the texture
  58631. * @param parsedTexture Define the JSON representation
  58632. * @param scene Define the scene the texture should be created in
  58633. * @param rootUrl Define the root url in case we need to load relative dependencies
  58634. * @returns the newly created texture after parsing
  58635. */
  58636. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58637. serialize(): any;
  58638. }
  58639. }
  58640. declare module BABYLON {
  58641. /**
  58642. * Class used to control physics engine
  58643. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58644. */
  58645. export class PhysicsEngine implements IPhysicsEngine {
  58646. private _physicsPlugin;
  58647. /**
  58648. * Global value used to control the smallest number supported by the simulation
  58649. */
  58650. static Epsilon: number;
  58651. private _impostors;
  58652. private _joints;
  58653. private _subTimeStep;
  58654. /**
  58655. * Gets the gravity vector used by the simulation
  58656. */
  58657. gravity: Vector3;
  58658. /**
  58659. * Factory used to create the default physics plugin.
  58660. * @returns The default physics plugin
  58661. */
  58662. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58663. /**
  58664. * Creates a new Physics Engine
  58665. * @param gravity defines the gravity vector used by the simulation
  58666. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58667. */
  58668. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58669. /**
  58670. * Sets the gravity vector used by the simulation
  58671. * @param gravity defines the gravity vector to use
  58672. */
  58673. setGravity(gravity: Vector3): void;
  58674. /**
  58675. * Set the time step of the physics engine.
  58676. * Default is 1/60.
  58677. * To slow it down, enter 1/600 for example.
  58678. * To speed it up, 1/30
  58679. * @param newTimeStep defines the new timestep to apply to this world.
  58680. */
  58681. setTimeStep(newTimeStep?: number): void;
  58682. /**
  58683. * Get the time step of the physics engine.
  58684. * @returns the current time step
  58685. */
  58686. getTimeStep(): number;
  58687. /**
  58688. * Set the sub time step of the physics engine.
  58689. * Default is 0 meaning there is no sub steps
  58690. * To increase physics resolution precision, set a small value (like 1 ms)
  58691. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58692. */
  58693. setSubTimeStep(subTimeStep?: number): void;
  58694. /**
  58695. * Get the sub time step of the physics engine.
  58696. * @returns the current sub time step
  58697. */
  58698. getSubTimeStep(): number;
  58699. /**
  58700. * Release all resources
  58701. */
  58702. dispose(): void;
  58703. /**
  58704. * Gets the name of the current physics plugin
  58705. * @returns the name of the plugin
  58706. */
  58707. getPhysicsPluginName(): string;
  58708. /**
  58709. * Adding a new impostor for the impostor tracking.
  58710. * This will be done by the impostor itself.
  58711. * @param impostor the impostor to add
  58712. */
  58713. addImpostor(impostor: PhysicsImpostor): void;
  58714. /**
  58715. * Remove an impostor from the engine.
  58716. * This impostor and its mesh will not longer be updated by the physics engine.
  58717. * @param impostor the impostor to remove
  58718. */
  58719. removeImpostor(impostor: PhysicsImpostor): void;
  58720. /**
  58721. * Add a joint to the physics engine
  58722. * @param mainImpostor defines the main impostor to which the joint is added.
  58723. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58724. * @param joint defines the joint that will connect both impostors.
  58725. */
  58726. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58727. /**
  58728. * Removes a joint from the simulation
  58729. * @param mainImpostor defines the impostor used with the joint
  58730. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58731. * @param joint defines the joint to remove
  58732. */
  58733. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58734. /**
  58735. * Called by the scene. No need to call it.
  58736. * @param delta defines the timespam between frames
  58737. */
  58738. _step(delta: number): void;
  58739. /**
  58740. * Gets the current plugin used to run the simulation
  58741. * @returns current plugin
  58742. */
  58743. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58744. /**
  58745. * Gets the list of physic impostors
  58746. * @returns an array of PhysicsImpostor
  58747. */
  58748. getImpostors(): Array<PhysicsImpostor>;
  58749. /**
  58750. * Gets the impostor for a physics enabled object
  58751. * @param object defines the object impersonated by the impostor
  58752. * @returns the PhysicsImpostor or null if not found
  58753. */
  58754. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58755. /**
  58756. * Gets the impostor for a physics body object
  58757. * @param body defines physics body used by the impostor
  58758. * @returns the PhysicsImpostor or null if not found
  58759. */
  58760. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58761. /**
  58762. * Does a raycast in the physics world
  58763. * @param from when should the ray start?
  58764. * @param to when should the ray end?
  58765. * @returns PhysicsRaycastResult
  58766. */
  58767. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58768. }
  58769. }
  58770. declare module BABYLON {
  58771. /** @hidden */
  58772. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58773. private _useDeltaForWorldStep;
  58774. world: any;
  58775. name: string;
  58776. private _physicsMaterials;
  58777. private _fixedTimeStep;
  58778. private _cannonRaycastResult;
  58779. private _raycastResult;
  58780. private _physicsBodysToRemoveAfterStep;
  58781. private _firstFrame;
  58782. BJSCANNON: any;
  58783. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58784. setGravity(gravity: Vector3): void;
  58785. setTimeStep(timeStep: number): void;
  58786. getTimeStep(): number;
  58787. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58788. private _removeMarkedPhysicsBodiesFromWorld;
  58789. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58790. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58791. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58792. private _processChildMeshes;
  58793. removePhysicsBody(impostor: PhysicsImpostor): void;
  58794. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58795. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58796. private _addMaterial;
  58797. private _checkWithEpsilon;
  58798. private _createShape;
  58799. private _createHeightmap;
  58800. private _minus90X;
  58801. private _plus90X;
  58802. private _tmpPosition;
  58803. private _tmpDeltaPosition;
  58804. private _tmpUnityRotation;
  58805. private _updatePhysicsBodyTransformation;
  58806. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58807. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58808. isSupported(): boolean;
  58809. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58810. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58811. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58812. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58813. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58814. getBodyMass(impostor: PhysicsImpostor): number;
  58815. getBodyFriction(impostor: PhysicsImpostor): number;
  58816. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58817. getBodyRestitution(impostor: PhysicsImpostor): number;
  58818. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58819. sleepBody(impostor: PhysicsImpostor): void;
  58820. wakeUpBody(impostor: PhysicsImpostor): void;
  58821. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58822. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58823. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58824. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58825. getRadius(impostor: PhysicsImpostor): number;
  58826. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58827. dispose(): void;
  58828. private _extendNamespace;
  58829. /**
  58830. * Does a raycast in the physics world
  58831. * @param from when should the ray start?
  58832. * @param to when should the ray end?
  58833. * @returns PhysicsRaycastResult
  58834. */
  58835. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58836. }
  58837. }
  58838. declare module BABYLON {
  58839. /** @hidden */
  58840. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58841. private _useDeltaForWorldStep;
  58842. world: any;
  58843. name: string;
  58844. BJSOIMO: any;
  58845. private _raycastResult;
  58846. private _fixedTimeStep;
  58847. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58848. setGravity(gravity: Vector3): void;
  58849. setTimeStep(timeStep: number): void;
  58850. getTimeStep(): number;
  58851. private _tmpImpostorsArray;
  58852. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58853. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58854. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58855. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58856. private _tmpPositionVector;
  58857. removePhysicsBody(impostor: PhysicsImpostor): void;
  58858. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58859. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58860. isSupported(): boolean;
  58861. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58862. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58863. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58864. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58865. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58866. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58867. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58868. getBodyMass(impostor: PhysicsImpostor): number;
  58869. getBodyFriction(impostor: PhysicsImpostor): number;
  58870. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58871. getBodyRestitution(impostor: PhysicsImpostor): number;
  58872. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58873. sleepBody(impostor: PhysicsImpostor): void;
  58874. wakeUpBody(impostor: PhysicsImpostor): void;
  58875. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58876. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58877. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58878. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58879. getRadius(impostor: PhysicsImpostor): number;
  58880. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58881. dispose(): void;
  58882. /**
  58883. * Does a raycast in the physics world
  58884. * @param from when should the ray start?
  58885. * @param to when should the ray end?
  58886. * @returns PhysicsRaycastResult
  58887. */
  58888. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58889. }
  58890. }
  58891. declare module BABYLON {
  58892. /**
  58893. * Class containing static functions to help procedurally build meshes
  58894. */
  58895. export class RibbonBuilder {
  58896. /**
  58897. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58898. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58899. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58900. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58901. * * 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
  58902. * * 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
  58903. * * 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
  58904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58905. * * 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
  58906. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58907. * * 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
  58908. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58909. * * 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
  58910. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58912. * @param name defines the name of the mesh
  58913. * @param options defines the options used to create the mesh
  58914. * @param scene defines the hosting scene
  58915. * @returns the ribbon mesh
  58916. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58917. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58918. */
  58919. static CreateRibbon(name: string, options: {
  58920. pathArray: Vector3[][];
  58921. closeArray?: boolean;
  58922. closePath?: boolean;
  58923. offset?: number;
  58924. updatable?: boolean;
  58925. sideOrientation?: number;
  58926. frontUVs?: Vector4;
  58927. backUVs?: Vector4;
  58928. instance?: Mesh;
  58929. invertUV?: boolean;
  58930. uvs?: Vector2[];
  58931. colors?: Color4[];
  58932. }, scene?: Nullable<Scene>): Mesh;
  58933. }
  58934. }
  58935. declare module BABYLON {
  58936. /**
  58937. * Class containing static functions to help procedurally build meshes
  58938. */
  58939. export class ShapeBuilder {
  58940. /**
  58941. * 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.
  58942. * * 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.
  58943. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58944. * * 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.
  58945. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58946. * * 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
  58947. * * 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
  58948. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58950. * * 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
  58951. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58953. * @param name defines the name of the mesh
  58954. * @param options defines the options used to create the mesh
  58955. * @param scene defines the hosting scene
  58956. * @returns the extruded shape mesh
  58957. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58958. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58959. */
  58960. static ExtrudeShape(name: string, options: {
  58961. shape: Vector3[];
  58962. path: Vector3[];
  58963. scale?: number;
  58964. rotation?: number;
  58965. cap?: number;
  58966. updatable?: boolean;
  58967. sideOrientation?: number;
  58968. frontUVs?: Vector4;
  58969. backUVs?: Vector4;
  58970. instance?: Mesh;
  58971. invertUV?: boolean;
  58972. }, scene?: Nullable<Scene>): Mesh;
  58973. /**
  58974. * Creates an custom extruded shape mesh.
  58975. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58976. * * 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.
  58977. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58978. * * 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
  58979. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58980. * * 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
  58981. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58982. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58983. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58984. * * 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
  58985. * * 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
  58986. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58988. * * 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
  58989. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58991. * @param name defines the name of the mesh
  58992. * @param options defines the options used to create the mesh
  58993. * @param scene defines the hosting scene
  58994. * @returns the custom extruded shape mesh
  58995. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58996. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58997. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58998. */
  58999. static ExtrudeShapeCustom(name: string, options: {
  59000. shape: Vector3[];
  59001. path: Vector3[];
  59002. scaleFunction?: any;
  59003. rotationFunction?: any;
  59004. ribbonCloseArray?: boolean;
  59005. ribbonClosePath?: boolean;
  59006. cap?: number;
  59007. updatable?: boolean;
  59008. sideOrientation?: number;
  59009. frontUVs?: Vector4;
  59010. backUVs?: Vector4;
  59011. instance?: Mesh;
  59012. invertUV?: boolean;
  59013. }, scene?: Nullable<Scene>): Mesh;
  59014. private static _ExtrudeShapeGeneric;
  59015. }
  59016. }
  59017. declare module BABYLON {
  59018. /**
  59019. * AmmoJS Physics plugin
  59020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59021. * @see https://github.com/kripken/ammo.js/
  59022. */
  59023. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59024. private _useDeltaForWorldStep;
  59025. /**
  59026. * Reference to the Ammo library
  59027. */
  59028. bjsAMMO: any;
  59029. /**
  59030. * Created ammoJS world which physics bodies are added to
  59031. */
  59032. world: any;
  59033. /**
  59034. * Name of the plugin
  59035. */
  59036. name: string;
  59037. private _timeStep;
  59038. private _fixedTimeStep;
  59039. private _maxSteps;
  59040. private _tmpQuaternion;
  59041. private _tmpAmmoTransform;
  59042. private _tmpAmmoQuaternion;
  59043. private _tmpAmmoConcreteContactResultCallback;
  59044. private _collisionConfiguration;
  59045. private _dispatcher;
  59046. private _overlappingPairCache;
  59047. private _solver;
  59048. private _softBodySolver;
  59049. private _tmpAmmoVectorA;
  59050. private _tmpAmmoVectorB;
  59051. private _tmpAmmoVectorC;
  59052. private _tmpAmmoVectorD;
  59053. private _tmpContactCallbackResult;
  59054. private _tmpAmmoVectorRCA;
  59055. private _tmpAmmoVectorRCB;
  59056. private _raycastResult;
  59057. private static readonly DISABLE_COLLISION_FLAG;
  59058. private static readonly KINEMATIC_FLAG;
  59059. private static readonly DISABLE_DEACTIVATION_FLAG;
  59060. /**
  59061. * Initializes the ammoJS plugin
  59062. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59063. * @param ammoInjection can be used to inject your own ammo reference
  59064. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59065. */
  59066. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59067. /**
  59068. * Sets the gravity of the physics world (m/(s^2))
  59069. * @param gravity Gravity to set
  59070. */
  59071. setGravity(gravity: Vector3): void;
  59072. /**
  59073. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59074. * @param timeStep timestep to use in seconds
  59075. */
  59076. setTimeStep(timeStep: number): void;
  59077. /**
  59078. * 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)
  59079. * @param fixedTimeStep fixedTimeStep to use in seconds
  59080. */
  59081. setFixedTimeStep(fixedTimeStep: number): void;
  59082. /**
  59083. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59084. * @param maxSteps the maximum number of steps by the physics engine per frame
  59085. */
  59086. setMaxSteps(maxSteps: number): void;
  59087. /**
  59088. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59089. * @returns the current timestep in seconds
  59090. */
  59091. getTimeStep(): number;
  59092. /**
  59093. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59094. */
  59095. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59096. private _isImpostorInContact;
  59097. private _isImpostorPairInContact;
  59098. private _stepSimulation;
  59099. /**
  59100. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59101. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59102. * After the step the babylon meshes are set to the position of the physics imposters
  59103. * @param delta amount of time to step forward
  59104. * @param impostors array of imposters to update before/after the step
  59105. */
  59106. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59107. /**
  59108. * Update babylon mesh to match physics world object
  59109. * @param impostor imposter to match
  59110. */
  59111. private _afterSoftStep;
  59112. /**
  59113. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59114. * @param impostor imposter to match
  59115. */
  59116. private _ropeStep;
  59117. /**
  59118. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59119. * @param impostor imposter to match
  59120. */
  59121. private _softbodyOrClothStep;
  59122. private _tmpMatrix;
  59123. /**
  59124. * Applies an impulse on the imposter
  59125. * @param impostor imposter to apply impulse to
  59126. * @param force amount of force to be applied to the imposter
  59127. * @param contactPoint the location to apply the impulse on the imposter
  59128. */
  59129. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59130. /**
  59131. * Applies a force on the imposter
  59132. * @param impostor imposter to apply force
  59133. * @param force amount of force to be applied to the imposter
  59134. * @param contactPoint the location to apply the force on the imposter
  59135. */
  59136. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59137. /**
  59138. * Creates a physics body using the plugin
  59139. * @param impostor the imposter to create the physics body on
  59140. */
  59141. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59142. /**
  59143. * Removes the physics body from the imposter and disposes of the body's memory
  59144. * @param impostor imposter to remove the physics body from
  59145. */
  59146. removePhysicsBody(impostor: PhysicsImpostor): void;
  59147. /**
  59148. * Generates a joint
  59149. * @param impostorJoint the imposter joint to create the joint with
  59150. */
  59151. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59152. /**
  59153. * Removes a joint
  59154. * @param impostorJoint the imposter joint to remove the joint from
  59155. */
  59156. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59157. private _addMeshVerts;
  59158. /**
  59159. * Initialise the soft body vertices to match its object's (mesh) vertices
  59160. * Softbody vertices (nodes) are in world space and to match this
  59161. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59162. * @param impostor to create the softbody for
  59163. */
  59164. private _softVertexData;
  59165. /**
  59166. * Create an impostor's soft body
  59167. * @param impostor to create the softbody for
  59168. */
  59169. private _createSoftbody;
  59170. /**
  59171. * Create cloth for an impostor
  59172. * @param impostor to create the softbody for
  59173. */
  59174. private _createCloth;
  59175. /**
  59176. * Create rope for an impostor
  59177. * @param impostor to create the softbody for
  59178. */
  59179. private _createRope;
  59180. /**
  59181. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59182. * @param impostor to create the custom physics shape for
  59183. */
  59184. private _createCustom;
  59185. private _addHullVerts;
  59186. private _createShape;
  59187. /**
  59188. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59189. * @param impostor imposter containing the physics body and babylon object
  59190. */
  59191. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59192. /**
  59193. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59194. * @param impostor imposter containing the physics body and babylon object
  59195. * @param newPosition new position
  59196. * @param newRotation new rotation
  59197. */
  59198. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59199. /**
  59200. * If this plugin is supported
  59201. * @returns true if its supported
  59202. */
  59203. isSupported(): boolean;
  59204. /**
  59205. * Sets the linear velocity of the physics body
  59206. * @param impostor imposter to set the velocity on
  59207. * @param velocity velocity to set
  59208. */
  59209. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59210. /**
  59211. * Sets the angular velocity of the physics body
  59212. * @param impostor imposter to set the velocity on
  59213. * @param velocity velocity to set
  59214. */
  59215. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59216. /**
  59217. * gets the linear velocity
  59218. * @param impostor imposter to get linear velocity from
  59219. * @returns linear velocity
  59220. */
  59221. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59222. /**
  59223. * gets the angular velocity
  59224. * @param impostor imposter to get angular velocity from
  59225. * @returns angular velocity
  59226. */
  59227. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59228. /**
  59229. * Sets the mass of physics body
  59230. * @param impostor imposter to set the mass on
  59231. * @param mass mass to set
  59232. */
  59233. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59234. /**
  59235. * Gets the mass of the physics body
  59236. * @param impostor imposter to get the mass from
  59237. * @returns mass
  59238. */
  59239. getBodyMass(impostor: PhysicsImpostor): number;
  59240. /**
  59241. * Gets friction of the impostor
  59242. * @param impostor impostor to get friction from
  59243. * @returns friction value
  59244. */
  59245. getBodyFriction(impostor: PhysicsImpostor): number;
  59246. /**
  59247. * Sets friction of the impostor
  59248. * @param impostor impostor to set friction on
  59249. * @param friction friction value
  59250. */
  59251. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59252. /**
  59253. * Gets restitution of the impostor
  59254. * @param impostor impostor to get restitution from
  59255. * @returns restitution value
  59256. */
  59257. getBodyRestitution(impostor: PhysicsImpostor): number;
  59258. /**
  59259. * Sets resitution of the impostor
  59260. * @param impostor impostor to set resitution on
  59261. * @param restitution resitution value
  59262. */
  59263. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59264. /**
  59265. * Gets pressure inside the impostor
  59266. * @param impostor impostor to get pressure from
  59267. * @returns pressure value
  59268. */
  59269. getBodyPressure(impostor: PhysicsImpostor): number;
  59270. /**
  59271. * Sets pressure inside a soft body impostor
  59272. * Cloth and rope must remain 0 pressure
  59273. * @param impostor impostor to set pressure on
  59274. * @param pressure pressure value
  59275. */
  59276. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59277. /**
  59278. * Gets stiffness of the impostor
  59279. * @param impostor impostor to get stiffness from
  59280. * @returns pressure value
  59281. */
  59282. getBodyStiffness(impostor: PhysicsImpostor): number;
  59283. /**
  59284. * Sets stiffness of the impostor
  59285. * @param impostor impostor to set stiffness on
  59286. * @param stiffness stiffness value from 0 to 1
  59287. */
  59288. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59289. /**
  59290. * Gets velocityIterations of the impostor
  59291. * @param impostor impostor to get velocity iterations from
  59292. * @returns velocityIterations value
  59293. */
  59294. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59295. /**
  59296. * Sets velocityIterations of the impostor
  59297. * @param impostor impostor to set velocity iterations on
  59298. * @param velocityIterations velocityIterations value
  59299. */
  59300. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59301. /**
  59302. * Gets positionIterations of the impostor
  59303. * @param impostor impostor to get position iterations from
  59304. * @returns positionIterations value
  59305. */
  59306. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59307. /**
  59308. * Sets positionIterations of the impostor
  59309. * @param impostor impostor to set position on
  59310. * @param positionIterations positionIterations value
  59311. */
  59312. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59313. /**
  59314. * Append an anchor to a cloth object
  59315. * @param impostor is the cloth impostor to add anchor to
  59316. * @param otherImpostor is the rigid impostor to anchor to
  59317. * @param width ratio across width from 0 to 1
  59318. * @param height ratio up height from 0 to 1
  59319. * @param influence the elasticity between cloth 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. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59323. /**
  59324. * Append an hook to a rope object
  59325. * @param impostor is the rope impostor to add hook to
  59326. * @param otherImpostor is the rigid impostor to hook to
  59327. * @param length ratio along the rope from 0 to 1
  59328. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59329. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59330. */
  59331. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59332. /**
  59333. * Sleeps the physics body and stops it from being active
  59334. * @param impostor impostor to sleep
  59335. */
  59336. sleepBody(impostor: PhysicsImpostor): void;
  59337. /**
  59338. * Activates the physics body
  59339. * @param impostor impostor to activate
  59340. */
  59341. wakeUpBody(impostor: PhysicsImpostor): void;
  59342. /**
  59343. * Updates the distance parameters of the joint
  59344. * @param joint joint to update
  59345. * @param maxDistance maximum distance of the joint
  59346. * @param minDistance minimum distance of the joint
  59347. */
  59348. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59349. /**
  59350. * Sets a motor on the joint
  59351. * @param joint joint to set motor on
  59352. * @param speed speed of the motor
  59353. * @param maxForce maximum force of the motor
  59354. * @param motorIndex index of the motor
  59355. */
  59356. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59357. /**
  59358. * Sets the motors limit
  59359. * @param joint joint to set limit on
  59360. * @param upperLimit upper limit
  59361. * @param lowerLimit lower limit
  59362. */
  59363. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59364. /**
  59365. * Syncs the position and rotation of a mesh with the impostor
  59366. * @param mesh mesh to sync
  59367. * @param impostor impostor to update the mesh with
  59368. */
  59369. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59370. /**
  59371. * Gets the radius of the impostor
  59372. * @param impostor impostor to get radius from
  59373. * @returns the radius
  59374. */
  59375. getRadius(impostor: PhysicsImpostor): number;
  59376. /**
  59377. * Gets the box size of the impostor
  59378. * @param impostor impostor to get box size from
  59379. * @param result the resulting box size
  59380. */
  59381. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59382. /**
  59383. * Disposes of the impostor
  59384. */
  59385. dispose(): void;
  59386. /**
  59387. * Does a raycast in the physics world
  59388. * @param from when should the ray start?
  59389. * @param to when should the ray end?
  59390. * @returns PhysicsRaycastResult
  59391. */
  59392. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59393. }
  59394. }
  59395. declare module BABYLON {
  59396. interface AbstractScene {
  59397. /**
  59398. * The list of reflection probes added to the scene
  59399. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59400. */
  59401. reflectionProbes: Array<ReflectionProbe>;
  59402. /**
  59403. * Removes the given reflection probe from this scene.
  59404. * @param toRemove The reflection probe to remove
  59405. * @returns The index of the removed reflection probe
  59406. */
  59407. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59408. /**
  59409. * Adds the given reflection probe to this scene.
  59410. * @param newReflectionProbe The reflection probe to add
  59411. */
  59412. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59413. }
  59414. /**
  59415. * Class used to generate realtime reflection / refraction cube textures
  59416. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59417. */
  59418. export class ReflectionProbe {
  59419. /** defines the name of the probe */
  59420. name: string;
  59421. private _scene;
  59422. private _renderTargetTexture;
  59423. private _projectionMatrix;
  59424. private _viewMatrix;
  59425. private _target;
  59426. private _add;
  59427. private _attachedMesh;
  59428. private _invertYAxis;
  59429. /** Gets or sets probe position (center of the cube map) */
  59430. position: Vector3;
  59431. /**
  59432. * Creates a new reflection probe
  59433. * @param name defines the name of the probe
  59434. * @param size defines the texture resolution (for each face)
  59435. * @param scene defines the hosting scene
  59436. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59437. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59438. */
  59439. constructor(
  59440. /** defines the name of the probe */
  59441. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59442. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59443. get samples(): number;
  59444. set samples(value: number);
  59445. /** Gets or sets the refresh rate to use (on every frame by default) */
  59446. get refreshRate(): number;
  59447. set refreshRate(value: number);
  59448. /**
  59449. * Gets the hosting scene
  59450. * @returns a Scene
  59451. */
  59452. getScene(): Scene;
  59453. /** Gets the internal CubeTexture used to render to */
  59454. get cubeTexture(): RenderTargetTexture;
  59455. /** Gets the list of meshes to render */
  59456. get renderList(): Nullable<AbstractMesh[]>;
  59457. /**
  59458. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59459. * @param mesh defines the mesh to attach to
  59460. */
  59461. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59462. /**
  59463. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59464. * @param renderingGroupId The rendering group id corresponding to its index
  59465. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59466. */
  59467. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59468. /**
  59469. * Clean all associated resources
  59470. */
  59471. dispose(): void;
  59472. /**
  59473. * Converts the reflection probe information to a readable string for debug purpose.
  59474. * @param fullDetails Supports for multiple levels of logging within scene loading
  59475. * @returns the human readable reflection probe info
  59476. */
  59477. toString(fullDetails?: boolean): string;
  59478. /**
  59479. * Get the class name of the relfection probe.
  59480. * @returns "ReflectionProbe"
  59481. */
  59482. getClassName(): string;
  59483. /**
  59484. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59485. * @returns The JSON representation of the texture
  59486. */
  59487. serialize(): any;
  59488. /**
  59489. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59490. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59491. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59492. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59493. * @returns The parsed reflection probe if successful
  59494. */
  59495. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59496. }
  59497. }
  59498. declare module BABYLON {
  59499. /** @hidden */
  59500. export var _BabylonLoaderRegistered: boolean;
  59501. /**
  59502. * Helps setting up some configuration for the babylon file loader.
  59503. */
  59504. export class BabylonFileLoaderConfiguration {
  59505. /**
  59506. * The loader does not allow injecting custom physix engine into the plugins.
  59507. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59508. * So you could set this variable to your engine import to make it work.
  59509. */
  59510. static LoaderInjectedPhysicsEngine: any;
  59511. }
  59512. }
  59513. declare module BABYLON {
  59514. /**
  59515. * The Physically based simple base material of BJS.
  59516. *
  59517. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59518. * It is used as the base class for both the specGloss and metalRough conventions.
  59519. */
  59520. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59521. /**
  59522. * Number of Simultaneous lights allowed on the material.
  59523. */
  59524. maxSimultaneousLights: number;
  59525. /**
  59526. * If sets to true, disables all the lights affecting the material.
  59527. */
  59528. disableLighting: boolean;
  59529. /**
  59530. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59531. */
  59532. environmentTexture: BaseTexture;
  59533. /**
  59534. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59535. */
  59536. invertNormalMapX: boolean;
  59537. /**
  59538. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59539. */
  59540. invertNormalMapY: boolean;
  59541. /**
  59542. * Normal map used in the model.
  59543. */
  59544. normalTexture: BaseTexture;
  59545. /**
  59546. * Emissivie color used to self-illuminate the model.
  59547. */
  59548. emissiveColor: Color3;
  59549. /**
  59550. * Emissivie texture used to self-illuminate the model.
  59551. */
  59552. emissiveTexture: BaseTexture;
  59553. /**
  59554. * Occlusion Channel Strenght.
  59555. */
  59556. occlusionStrength: number;
  59557. /**
  59558. * Occlusion Texture of the material (adding extra occlusion effects).
  59559. */
  59560. occlusionTexture: BaseTexture;
  59561. /**
  59562. * Defines the alpha limits in alpha test mode.
  59563. */
  59564. alphaCutOff: number;
  59565. /**
  59566. * Gets the current double sided mode.
  59567. */
  59568. get doubleSided(): boolean;
  59569. /**
  59570. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59571. */
  59572. set doubleSided(value: boolean);
  59573. /**
  59574. * Stores the pre-calculated light information of a mesh in a texture.
  59575. */
  59576. lightmapTexture: BaseTexture;
  59577. /**
  59578. * If true, the light map contains occlusion information instead of lighting info.
  59579. */
  59580. useLightmapAsShadowmap: boolean;
  59581. /**
  59582. * Instantiates a new PBRMaterial instance.
  59583. *
  59584. * @param name The material name
  59585. * @param scene The scene the material will be use in.
  59586. */
  59587. constructor(name: string, scene: Scene);
  59588. getClassName(): string;
  59589. }
  59590. }
  59591. declare module BABYLON {
  59592. /**
  59593. * The PBR material of BJS following the metal roughness convention.
  59594. *
  59595. * This fits to the PBR convention in the GLTF definition:
  59596. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59597. */
  59598. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59599. /**
  59600. * The base color has two different interpretations depending on the value of metalness.
  59601. * When the material is a metal, the base color is the specific measured reflectance value
  59602. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59603. * of the material.
  59604. */
  59605. baseColor: Color3;
  59606. /**
  59607. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59608. * well as opacity information in the alpha channel.
  59609. */
  59610. baseTexture: BaseTexture;
  59611. /**
  59612. * Specifies the metallic scalar value of the material.
  59613. * Can also be used to scale the metalness values of the metallic texture.
  59614. */
  59615. metallic: number;
  59616. /**
  59617. * Specifies the roughness scalar value of the material.
  59618. * Can also be used to scale the roughness values of the metallic texture.
  59619. */
  59620. roughness: number;
  59621. /**
  59622. * Texture containing both the metallic value in the B channel and the
  59623. * roughness value in the G channel to keep better precision.
  59624. */
  59625. metallicRoughnessTexture: BaseTexture;
  59626. /**
  59627. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59628. *
  59629. * @param name The material name
  59630. * @param scene The scene the material will be use in.
  59631. */
  59632. constructor(name: string, scene: Scene);
  59633. /**
  59634. * Return the currrent class name of the material.
  59635. */
  59636. getClassName(): string;
  59637. /**
  59638. * Makes a duplicate of the current material.
  59639. * @param name - name to use for the new material.
  59640. */
  59641. clone(name: string): PBRMetallicRoughnessMaterial;
  59642. /**
  59643. * Serialize the material to a parsable JSON object.
  59644. */
  59645. serialize(): any;
  59646. /**
  59647. * Parses a JSON object correponding to the serialize function.
  59648. */
  59649. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59650. }
  59651. }
  59652. declare module BABYLON {
  59653. /**
  59654. * The PBR material of BJS following the specular glossiness convention.
  59655. *
  59656. * This fits to the PBR convention in the GLTF definition:
  59657. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59658. */
  59659. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59660. /**
  59661. * Specifies the diffuse color of the material.
  59662. */
  59663. diffuseColor: Color3;
  59664. /**
  59665. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59666. * channel.
  59667. */
  59668. diffuseTexture: BaseTexture;
  59669. /**
  59670. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59671. */
  59672. specularColor: Color3;
  59673. /**
  59674. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59675. */
  59676. glossiness: number;
  59677. /**
  59678. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59679. */
  59680. specularGlossinessTexture: BaseTexture;
  59681. /**
  59682. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59683. *
  59684. * @param name The material name
  59685. * @param scene The scene the material will be use in.
  59686. */
  59687. constructor(name: string, scene: Scene);
  59688. /**
  59689. * Return the currrent class name of the material.
  59690. */
  59691. getClassName(): string;
  59692. /**
  59693. * Makes a duplicate of the current material.
  59694. * @param name - name to use for the new material.
  59695. */
  59696. clone(name: string): PBRSpecularGlossinessMaterial;
  59697. /**
  59698. * Serialize the material to a parsable JSON object.
  59699. */
  59700. serialize(): any;
  59701. /**
  59702. * Parses a JSON object correponding to the serialize function.
  59703. */
  59704. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59705. }
  59706. }
  59707. declare module BABYLON {
  59708. /**
  59709. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59710. * It can help converting any input color in a desired output one. This can then be used to create effects
  59711. * from sepia, black and white to sixties or futuristic rendering...
  59712. *
  59713. * The only supported format is currently 3dl.
  59714. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59715. */
  59716. export class ColorGradingTexture extends BaseTexture {
  59717. /**
  59718. * The texture URL.
  59719. */
  59720. url: string;
  59721. /**
  59722. * Empty line regex stored for GC.
  59723. */
  59724. private static _noneEmptyLineRegex;
  59725. private _textureMatrix;
  59726. private _onLoad;
  59727. /**
  59728. * Instantiates a ColorGradingTexture from the following parameters.
  59729. *
  59730. * @param url The location of the color gradind data (currently only supporting 3dl)
  59731. * @param sceneOrEngine The scene or engine the texture will be used in
  59732. * @param onLoad defines a callback triggered when the texture has been loaded
  59733. */
  59734. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59735. /**
  59736. * Fires the onload event from the constructor if requested.
  59737. */
  59738. private _triggerOnLoad;
  59739. /**
  59740. * Returns the texture matrix used in most of the material.
  59741. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59742. */
  59743. getTextureMatrix(): Matrix;
  59744. /**
  59745. * Occurs when the file being loaded is a .3dl LUT file.
  59746. */
  59747. private load3dlTexture;
  59748. /**
  59749. * Starts the loading process of the texture.
  59750. */
  59751. private loadTexture;
  59752. /**
  59753. * Clones the color gradind texture.
  59754. */
  59755. clone(): ColorGradingTexture;
  59756. /**
  59757. * Called during delayed load for textures.
  59758. */
  59759. delayLoad(): void;
  59760. /**
  59761. * Parses a color grading texture serialized by Babylon.
  59762. * @param parsedTexture The texture information being parsedTexture
  59763. * @param scene The scene to load the texture in
  59764. * @param rootUrl The root url of the data assets to load
  59765. * @return A color gradind texture
  59766. */
  59767. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59768. /**
  59769. * Serializes the LUT texture to json format.
  59770. */
  59771. serialize(): any;
  59772. }
  59773. }
  59774. declare module BABYLON {
  59775. /**
  59776. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59777. */
  59778. export class EquiRectangularCubeTexture extends BaseTexture {
  59779. /** The six faces of the cube. */
  59780. private static _FacesMapping;
  59781. private _noMipmap;
  59782. private _onLoad;
  59783. private _onError;
  59784. /** The size of the cubemap. */
  59785. private _size;
  59786. /** The buffer of the image. */
  59787. private _buffer;
  59788. /** The width of the input image. */
  59789. private _width;
  59790. /** The height of the input image. */
  59791. private _height;
  59792. /** The URL to the image. */
  59793. url: string;
  59794. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59795. coordinatesMode: number;
  59796. /**
  59797. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59798. * @param url The location of the image
  59799. * @param scene The scene the texture will be used in
  59800. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59801. * @param noMipmap Forces to not generate the mipmap if true
  59802. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59803. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59804. * @param onLoad — defines a callback called when texture is loaded
  59805. * @param onError — defines a callback called if there is an error
  59806. */
  59807. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59808. /**
  59809. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59810. */
  59811. private loadImage;
  59812. /**
  59813. * Convert the image buffer into a cubemap and create a CubeTexture.
  59814. */
  59815. private loadTexture;
  59816. /**
  59817. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59818. * @param buffer The ArrayBuffer that should be converted.
  59819. * @returns The buffer as Float32Array.
  59820. */
  59821. private getFloat32ArrayFromArrayBuffer;
  59822. /**
  59823. * Get the current class name of the texture useful for serialization or dynamic coding.
  59824. * @returns "EquiRectangularCubeTexture"
  59825. */
  59826. getClassName(): string;
  59827. /**
  59828. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59829. * @returns A clone of the current EquiRectangularCubeTexture.
  59830. */
  59831. clone(): EquiRectangularCubeTexture;
  59832. }
  59833. }
  59834. declare module BABYLON {
  59835. /**
  59836. * Defines the options related to the creation of an HtmlElementTexture
  59837. */
  59838. export interface IHtmlElementTextureOptions {
  59839. /**
  59840. * Defines wether mip maps should be created or not.
  59841. */
  59842. generateMipMaps?: boolean;
  59843. /**
  59844. * Defines the sampling mode of the texture.
  59845. */
  59846. samplingMode?: number;
  59847. /**
  59848. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59849. */
  59850. engine: Nullable<ThinEngine>;
  59851. /**
  59852. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59853. */
  59854. scene: Nullable<Scene>;
  59855. }
  59856. /**
  59857. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59858. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59859. * is automatically managed.
  59860. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59861. * in your application.
  59862. *
  59863. * As the update is not automatic, you need to call them manually.
  59864. */
  59865. export class HtmlElementTexture extends BaseTexture {
  59866. /**
  59867. * The texture URL.
  59868. */
  59869. element: HTMLVideoElement | HTMLCanvasElement;
  59870. private static readonly DefaultOptions;
  59871. private _textureMatrix;
  59872. private _isVideo;
  59873. private _generateMipMaps;
  59874. private _samplingMode;
  59875. /**
  59876. * Instantiates a HtmlElementTexture from the following parameters.
  59877. *
  59878. * @param name Defines the name of the texture
  59879. * @param element Defines the video or canvas the texture is filled with
  59880. * @param options Defines the other none mandatory texture creation options
  59881. */
  59882. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59883. private _createInternalTexture;
  59884. /**
  59885. * Returns the texture matrix used in most of the material.
  59886. */
  59887. getTextureMatrix(): Matrix;
  59888. /**
  59889. * Updates the content of the texture.
  59890. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59891. */
  59892. update(invertY?: Nullable<boolean>): void;
  59893. }
  59894. }
  59895. declare module BABYLON {
  59896. /**
  59897. * Based on jsTGALoader - Javascript loader for TGA file
  59898. * By Vincent Thibault
  59899. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59900. */
  59901. export class TGATools {
  59902. private static _TYPE_INDEXED;
  59903. private static _TYPE_RGB;
  59904. private static _TYPE_GREY;
  59905. private static _TYPE_RLE_INDEXED;
  59906. private static _TYPE_RLE_RGB;
  59907. private static _TYPE_RLE_GREY;
  59908. private static _ORIGIN_MASK;
  59909. private static _ORIGIN_SHIFT;
  59910. private static _ORIGIN_BL;
  59911. private static _ORIGIN_BR;
  59912. private static _ORIGIN_UL;
  59913. private static _ORIGIN_UR;
  59914. /**
  59915. * Gets the header of a TGA file
  59916. * @param data defines the TGA data
  59917. * @returns the header
  59918. */
  59919. static GetTGAHeader(data: Uint8Array): any;
  59920. /**
  59921. * Uploads TGA content to a Babylon Texture
  59922. * @hidden
  59923. */
  59924. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59925. /** @hidden */
  59926. 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;
  59927. /** @hidden */
  59928. 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;
  59929. /** @hidden */
  59930. 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;
  59931. /** @hidden */
  59932. 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;
  59933. /** @hidden */
  59934. 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;
  59935. /** @hidden */
  59936. 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;
  59937. }
  59938. }
  59939. declare module BABYLON {
  59940. /**
  59941. * Implementation of the TGA Texture Loader.
  59942. * @hidden
  59943. */
  59944. export class _TGATextureLoader implements IInternalTextureLoader {
  59945. /**
  59946. * Defines wether the loader supports cascade loading the different faces.
  59947. */
  59948. readonly supportCascades: boolean;
  59949. /**
  59950. * This returns if the loader support the current file information.
  59951. * @param extension defines the file extension of the file being loaded
  59952. * @returns true if the loader can load the specified file
  59953. */
  59954. canLoad(extension: string): boolean;
  59955. /**
  59956. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59957. * @param data contains the texture data
  59958. * @param texture defines the BabylonJS internal texture
  59959. * @param createPolynomials will be true if polynomials have been requested
  59960. * @param onLoad defines the callback to trigger once the texture is ready
  59961. * @param onError defines the callback to trigger in case of error
  59962. */
  59963. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59964. /**
  59965. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59966. * @param data contains the texture data
  59967. * @param texture defines the BabylonJS internal texture
  59968. * @param callback defines the method to call once ready to upload
  59969. */
  59970. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59971. }
  59972. }
  59973. declare module BABYLON {
  59974. /**
  59975. * Info about the .basis files
  59976. */
  59977. class BasisFileInfo {
  59978. /**
  59979. * If the file has alpha
  59980. */
  59981. hasAlpha: boolean;
  59982. /**
  59983. * Info about each image of the basis file
  59984. */
  59985. images: Array<{
  59986. levels: Array<{
  59987. width: number;
  59988. height: number;
  59989. transcodedPixels: ArrayBufferView;
  59990. }>;
  59991. }>;
  59992. }
  59993. /**
  59994. * Result of transcoding a basis file
  59995. */
  59996. class TranscodeResult {
  59997. /**
  59998. * Info about the .basis file
  59999. */
  60000. fileInfo: BasisFileInfo;
  60001. /**
  60002. * Format to use when loading the file
  60003. */
  60004. format: number;
  60005. }
  60006. /**
  60007. * Configuration options for the Basis transcoder
  60008. */
  60009. export class BasisTranscodeConfiguration {
  60010. /**
  60011. * Supported compression formats used to determine the supported output format of the transcoder
  60012. */
  60013. supportedCompressionFormats?: {
  60014. /**
  60015. * etc1 compression format
  60016. */
  60017. etc1?: boolean;
  60018. /**
  60019. * s3tc compression format
  60020. */
  60021. s3tc?: boolean;
  60022. /**
  60023. * pvrtc compression format
  60024. */
  60025. pvrtc?: boolean;
  60026. /**
  60027. * etc2 compression format
  60028. */
  60029. etc2?: boolean;
  60030. };
  60031. /**
  60032. * If mipmap levels should be loaded for transcoded images (Default: true)
  60033. */
  60034. loadMipmapLevels?: boolean;
  60035. /**
  60036. * Index of a single image to load (Default: all images)
  60037. */
  60038. loadSingleImage?: number;
  60039. }
  60040. /**
  60041. * Used to load .Basis files
  60042. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60043. */
  60044. export class BasisTools {
  60045. private static _IgnoreSupportedFormats;
  60046. /**
  60047. * URL to use when loading the basis transcoder
  60048. */
  60049. static JSModuleURL: string;
  60050. /**
  60051. * URL to use when loading the wasm module for the transcoder
  60052. */
  60053. static WasmModuleURL: string;
  60054. /**
  60055. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60056. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60057. * @returns internal format corresponding to the Basis format
  60058. */
  60059. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60060. private static _WorkerPromise;
  60061. private static _Worker;
  60062. private static _actionId;
  60063. private static _CreateWorkerAsync;
  60064. /**
  60065. * Transcodes a loaded image file to compressed pixel data
  60066. * @param data image data to transcode
  60067. * @param config configuration options for the transcoding
  60068. * @returns a promise resulting in the transcoded image
  60069. */
  60070. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60071. /**
  60072. * Loads a texture from the transcode result
  60073. * @param texture texture load to
  60074. * @param transcodeResult the result of transcoding the basis file to load from
  60075. */
  60076. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60077. }
  60078. }
  60079. declare module BABYLON {
  60080. /**
  60081. * Loader for .basis file format
  60082. */
  60083. export class _BasisTextureLoader implements IInternalTextureLoader {
  60084. /**
  60085. * Defines whether the loader supports cascade loading the different faces.
  60086. */
  60087. readonly supportCascades: boolean;
  60088. /**
  60089. * This returns if the loader support the current file information.
  60090. * @param extension defines the file extension of the file being loaded
  60091. * @returns true if the loader can load the specified file
  60092. */
  60093. canLoad(extension: string): boolean;
  60094. /**
  60095. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60096. * @param data contains the texture data
  60097. * @param texture defines the BabylonJS internal texture
  60098. * @param createPolynomials will be true if polynomials have been requested
  60099. * @param onLoad defines the callback to trigger once the texture is ready
  60100. * @param onError defines the callback to trigger in case of error
  60101. */
  60102. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60103. /**
  60104. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60105. * @param data contains the texture data
  60106. * @param texture defines the BabylonJS internal texture
  60107. * @param callback defines the method to call once ready to upload
  60108. */
  60109. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60110. }
  60111. }
  60112. declare module BABYLON {
  60113. /**
  60114. * Defines the basic options interface of a TexturePacker Frame
  60115. */
  60116. export interface ITexturePackerFrame {
  60117. /**
  60118. * The frame ID
  60119. */
  60120. id: number;
  60121. /**
  60122. * The frames Scale
  60123. */
  60124. scale: Vector2;
  60125. /**
  60126. * The Frames offset
  60127. */
  60128. offset: Vector2;
  60129. }
  60130. /**
  60131. * This is a support class for frame Data on texture packer sets.
  60132. */
  60133. export class TexturePackerFrame implements ITexturePackerFrame {
  60134. /**
  60135. * The frame ID
  60136. */
  60137. id: number;
  60138. /**
  60139. * The frames Scale
  60140. */
  60141. scale: Vector2;
  60142. /**
  60143. * The Frames offset
  60144. */
  60145. offset: Vector2;
  60146. /**
  60147. * Initializes a texture package frame.
  60148. * @param id The numerical frame identifier
  60149. * @param scale Scalar Vector2 for UV frame
  60150. * @param offset Vector2 for the frame position in UV units.
  60151. * @returns TexturePackerFrame
  60152. */
  60153. constructor(id: number, scale: Vector2, offset: Vector2);
  60154. }
  60155. }
  60156. declare module BABYLON {
  60157. /**
  60158. * Defines the basic options interface of a TexturePacker
  60159. */
  60160. export interface ITexturePackerOptions {
  60161. /**
  60162. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60163. */
  60164. map?: string[];
  60165. /**
  60166. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60167. */
  60168. uvsIn?: string;
  60169. /**
  60170. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60171. */
  60172. uvsOut?: string;
  60173. /**
  60174. * number representing the layout style. Defaults to LAYOUT_STRIP
  60175. */
  60176. layout?: number;
  60177. /**
  60178. * number of columns if using custom column count layout(2). This defaults to 4.
  60179. */
  60180. colnum?: number;
  60181. /**
  60182. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60183. */
  60184. updateInputMeshes?: boolean;
  60185. /**
  60186. * boolean flag to dispose all the source textures. Defaults to true.
  60187. */
  60188. disposeSources?: boolean;
  60189. /**
  60190. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60191. */
  60192. fillBlanks?: boolean;
  60193. /**
  60194. * string value representing the context fill style color. Defaults to 'black'.
  60195. */
  60196. customFillColor?: string;
  60197. /**
  60198. * Width and Height Value of each Frame in the TexturePacker Sets
  60199. */
  60200. frameSize?: number;
  60201. /**
  60202. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60203. */
  60204. paddingRatio?: number;
  60205. /**
  60206. * Number that declares the fill method for the padding gutter.
  60207. */
  60208. paddingMode?: number;
  60209. /**
  60210. * If in SUBUV_COLOR padding mode what color to use.
  60211. */
  60212. paddingColor?: Color3 | Color4;
  60213. }
  60214. /**
  60215. * Defines the basic interface of a TexturePacker JSON File
  60216. */
  60217. export interface ITexturePackerJSON {
  60218. /**
  60219. * The frame ID
  60220. */
  60221. name: string;
  60222. /**
  60223. * The base64 channel data
  60224. */
  60225. sets: any;
  60226. /**
  60227. * The options of the Packer
  60228. */
  60229. options: ITexturePackerOptions;
  60230. /**
  60231. * The frame data of the Packer
  60232. */
  60233. frames: Array<number>;
  60234. }
  60235. /**
  60236. * This is a support class that generates a series of packed texture sets.
  60237. * @see https://doc.babylonjs.com/babylon101/materials
  60238. */
  60239. export class TexturePacker {
  60240. /** Packer Layout Constant 0 */
  60241. static readonly LAYOUT_STRIP: number;
  60242. /** Packer Layout Constant 1 */
  60243. static readonly LAYOUT_POWER2: number;
  60244. /** Packer Layout Constant 2 */
  60245. static readonly LAYOUT_COLNUM: number;
  60246. /** Packer Layout Constant 0 */
  60247. static readonly SUBUV_WRAP: number;
  60248. /** Packer Layout Constant 1 */
  60249. static readonly SUBUV_EXTEND: number;
  60250. /** Packer Layout Constant 2 */
  60251. static readonly SUBUV_COLOR: number;
  60252. /** The Name of the Texture Package */
  60253. name: string;
  60254. /** The scene scope of the TexturePacker */
  60255. scene: Scene;
  60256. /** The Meshes to target */
  60257. meshes: AbstractMesh[];
  60258. /** Arguments passed with the Constructor */
  60259. options: ITexturePackerOptions;
  60260. /** The promise that is started upon initialization */
  60261. promise: Nullable<Promise<TexturePacker | string>>;
  60262. /** The Container object for the channel sets that are generated */
  60263. sets: object;
  60264. /** The Container array for the frames that are generated */
  60265. frames: TexturePackerFrame[];
  60266. /** The expected number of textures the system is parsing. */
  60267. private _expecting;
  60268. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60269. private _paddingValue;
  60270. /**
  60271. * Initializes a texture package series from an array of meshes or a single mesh.
  60272. * @param name The name of the package
  60273. * @param meshes The target meshes to compose the package from
  60274. * @param options The arguments that texture packer should follow while building.
  60275. * @param scene The scene which the textures are scoped to.
  60276. * @returns TexturePacker
  60277. */
  60278. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60279. /**
  60280. * Starts the package process
  60281. * @param resolve The promises resolution function
  60282. * @returns TexturePacker
  60283. */
  60284. private _createFrames;
  60285. /**
  60286. * Calculates the Size of the Channel Sets
  60287. * @returns Vector2
  60288. */
  60289. private _calculateSize;
  60290. /**
  60291. * Calculates the UV data for the frames.
  60292. * @param baseSize the base frameSize
  60293. * @param padding the base frame padding
  60294. * @param dtSize size of the Dynamic Texture for that channel
  60295. * @param dtUnits is 1/dtSize
  60296. * @param update flag to update the input meshes
  60297. */
  60298. private _calculateMeshUVFrames;
  60299. /**
  60300. * Calculates the frames Offset.
  60301. * @param index of the frame
  60302. * @returns Vector2
  60303. */
  60304. private _getFrameOffset;
  60305. /**
  60306. * Updates a Mesh to the frame data
  60307. * @param mesh that is the target
  60308. * @param frameID or the frame index
  60309. */
  60310. private _updateMeshUV;
  60311. /**
  60312. * Updates a Meshes materials to use the texture packer channels
  60313. * @param m is the mesh to target
  60314. * @param force all channels on the packer to be set.
  60315. */
  60316. private _updateTextureReferences;
  60317. /**
  60318. * Public method to set a Mesh to a frame
  60319. * @param m that is the target
  60320. * @param frameID or the frame index
  60321. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60322. */
  60323. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60324. /**
  60325. * Starts the async promise to compile the texture packer.
  60326. * @returns Promise<void>
  60327. */
  60328. processAsync(): Promise<void>;
  60329. /**
  60330. * Disposes all textures associated with this packer
  60331. */
  60332. dispose(): void;
  60333. /**
  60334. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60335. * @param imageType is the image type to use.
  60336. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60337. */
  60338. download(imageType?: string, quality?: number): void;
  60339. /**
  60340. * Public method to load a texturePacker JSON file.
  60341. * @param data of the JSON file in string format.
  60342. */
  60343. updateFromJSON(data: string): void;
  60344. }
  60345. }
  60346. declare module BABYLON {
  60347. /**
  60348. * 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.
  60349. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60350. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60351. */
  60352. export class CustomProceduralTexture extends ProceduralTexture {
  60353. private _animate;
  60354. private _time;
  60355. private _config;
  60356. private _texturePath;
  60357. /**
  60358. * Instantiates a new Custom Procedural Texture.
  60359. * 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.
  60360. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60361. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60362. * @param name Define the name of the texture
  60363. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60364. * @param size Define the size of the texture to create
  60365. * @param scene Define the scene the texture belongs to
  60366. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60367. * @param generateMipMaps Define if the texture should creates mip maps or not
  60368. */
  60369. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60370. private _loadJson;
  60371. /**
  60372. * Is the texture ready to be used ? (rendered at least once)
  60373. * @returns true if ready, otherwise, false.
  60374. */
  60375. isReady(): boolean;
  60376. /**
  60377. * Render the texture to its associated render target.
  60378. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60379. */
  60380. render(useCameraPostProcess?: boolean): void;
  60381. /**
  60382. * Update the list of dependant textures samplers in the shader.
  60383. */
  60384. updateTextures(): void;
  60385. /**
  60386. * Update the uniform values of the procedural texture in the shader.
  60387. */
  60388. updateShaderUniforms(): void;
  60389. /**
  60390. * Define if the texture animates or not.
  60391. */
  60392. get animate(): boolean;
  60393. set animate(value: boolean);
  60394. }
  60395. }
  60396. declare module BABYLON {
  60397. /** @hidden */
  60398. export var noisePixelShader: {
  60399. name: string;
  60400. shader: string;
  60401. };
  60402. }
  60403. declare module BABYLON {
  60404. /**
  60405. * Class used to generate noise procedural textures
  60406. */
  60407. export class NoiseProceduralTexture extends ProceduralTexture {
  60408. private _time;
  60409. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60410. brightness: number;
  60411. /** Defines the number of octaves to process */
  60412. octaves: number;
  60413. /** Defines the level of persistence (0.8 by default) */
  60414. persistence: number;
  60415. /** Gets or sets animation speed factor (default is 1) */
  60416. animationSpeedFactor: number;
  60417. /**
  60418. * Creates a new NoiseProceduralTexture
  60419. * @param name defines the name fo the texture
  60420. * @param size defines the size of the texture (default is 256)
  60421. * @param scene defines the hosting scene
  60422. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60423. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60424. */
  60425. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60426. private _updateShaderUniforms;
  60427. protected _getDefines(): string;
  60428. /** Generate the current state of the procedural texture */
  60429. render(useCameraPostProcess?: boolean): void;
  60430. /**
  60431. * Serializes this noise procedural texture
  60432. * @returns a serialized noise procedural texture object
  60433. */
  60434. serialize(): any;
  60435. /**
  60436. * Clone the texture.
  60437. * @returns the cloned texture
  60438. */
  60439. clone(): NoiseProceduralTexture;
  60440. /**
  60441. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60442. * @param parsedTexture defines parsed texture data
  60443. * @param scene defines the current scene
  60444. * @param rootUrl defines the root URL containing noise procedural texture information
  60445. * @returns a parsed NoiseProceduralTexture
  60446. */
  60447. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60448. }
  60449. }
  60450. declare module BABYLON {
  60451. /**
  60452. * Raw cube texture where the raw buffers are passed in
  60453. */
  60454. export class RawCubeTexture extends CubeTexture {
  60455. /**
  60456. * Creates a cube texture where the raw buffers are passed in.
  60457. * @param scene defines the scene the texture is attached to
  60458. * @param data defines the array of data to use to create each face
  60459. * @param size defines the size of the textures
  60460. * @param format defines the format of the data
  60461. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60462. * @param generateMipMaps defines if the engine should generate the mip levels
  60463. * @param invertY defines if data must be stored with Y axis inverted
  60464. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60465. * @param compression defines the compression used (null by default)
  60466. */
  60467. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60468. /**
  60469. * Updates the raw cube texture.
  60470. * @param data defines the data to store
  60471. * @param format defines the data format
  60472. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60473. * @param invertY defines if data must be stored with Y axis inverted
  60474. * @param compression defines the compression used (null by default)
  60475. * @param level defines which level of the texture to update
  60476. */
  60477. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60478. /**
  60479. * Updates a raw cube texture with RGBD encoded data.
  60480. * @param data defines the array of data [mipmap][face] to use to create each face
  60481. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60482. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60483. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60484. * @returns a promsie that resolves when the operation is complete
  60485. */
  60486. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60487. /**
  60488. * Clones the raw cube texture.
  60489. * @return a new cube texture
  60490. */
  60491. clone(): CubeTexture;
  60492. /** @hidden */
  60493. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60494. }
  60495. }
  60496. declare module BABYLON {
  60497. /**
  60498. * Class used to store 2D array textures containing user data
  60499. */
  60500. export class RawTexture2DArray extends Texture {
  60501. /** Gets or sets the texture format to use */
  60502. format: number;
  60503. /**
  60504. * Create a new RawTexture2DArray
  60505. * @param data defines the data of the texture
  60506. * @param width defines the width of the texture
  60507. * @param height defines the height of the texture
  60508. * @param depth defines the number of layers of the texture
  60509. * @param format defines the texture format to use
  60510. * @param scene defines the hosting scene
  60511. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60512. * @param invertY defines if texture must be stored with Y axis inverted
  60513. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60514. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60515. */
  60516. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60517. /** Gets or sets the texture format to use */
  60518. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60519. /**
  60520. * Update the texture with new data
  60521. * @param data defines the data to store in the texture
  60522. */
  60523. update(data: ArrayBufferView): void;
  60524. }
  60525. }
  60526. declare module BABYLON {
  60527. /**
  60528. * Class used to store 3D textures containing user data
  60529. */
  60530. export class RawTexture3D extends Texture {
  60531. /** Gets or sets the texture format to use */
  60532. format: number;
  60533. /**
  60534. * Create a new RawTexture3D
  60535. * @param data defines the data of the texture
  60536. * @param width defines the width of the texture
  60537. * @param height defines the height of the texture
  60538. * @param depth defines the depth of the texture
  60539. * @param format defines the texture format to use
  60540. * @param scene defines the hosting scene
  60541. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60542. * @param invertY defines if texture must be stored with Y axis inverted
  60543. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60544. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60545. */
  60546. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60547. /** Gets or sets the texture format to use */
  60548. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60549. /**
  60550. * Update the texture with new data
  60551. * @param data defines the data to store in the texture
  60552. */
  60553. update(data: ArrayBufferView): void;
  60554. }
  60555. }
  60556. declare module BABYLON {
  60557. /**
  60558. * Creates a refraction texture used by refraction channel of the standard material.
  60559. * It is like a mirror but to see through a material.
  60560. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60561. */
  60562. export class RefractionTexture extends RenderTargetTexture {
  60563. /**
  60564. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60565. * 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.
  60566. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60567. */
  60568. refractionPlane: Plane;
  60569. /**
  60570. * Define how deep under the surface we should see.
  60571. */
  60572. depth: number;
  60573. /**
  60574. * Creates a refraction texture used by refraction channel of the standard material.
  60575. * It is like a mirror but to see through a material.
  60576. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60577. * @param name Define the texture name
  60578. * @param size Define the size of the underlying texture
  60579. * @param scene Define the scene the refraction belongs to
  60580. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60581. */
  60582. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  60583. /**
  60584. * Clone the refraction texture.
  60585. * @returns the cloned texture
  60586. */
  60587. clone(): RefractionTexture;
  60588. /**
  60589. * Serialize the texture to a JSON representation you could use in Parse later on
  60590. * @returns the serialized JSON representation
  60591. */
  60592. serialize(): any;
  60593. }
  60594. }
  60595. declare module BABYLON {
  60596. /**
  60597. * Block used to add support for vertex skinning (bones)
  60598. */
  60599. export class BonesBlock extends NodeMaterialBlock {
  60600. /**
  60601. * Creates a new BonesBlock
  60602. * @param name defines the block name
  60603. */
  60604. constructor(name: string);
  60605. /**
  60606. * Initialize the block and prepare the context for build
  60607. * @param state defines the state that will be used for the build
  60608. */
  60609. initialize(state: NodeMaterialBuildState): void;
  60610. /**
  60611. * Gets the current class name
  60612. * @returns the class name
  60613. */
  60614. getClassName(): string;
  60615. /**
  60616. * Gets the matrix indices input component
  60617. */
  60618. get matricesIndices(): NodeMaterialConnectionPoint;
  60619. /**
  60620. * Gets the matrix weights input component
  60621. */
  60622. get matricesWeights(): NodeMaterialConnectionPoint;
  60623. /**
  60624. * Gets the extra matrix indices input component
  60625. */
  60626. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60627. /**
  60628. * Gets the extra matrix weights input component
  60629. */
  60630. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60631. /**
  60632. * Gets the world input component
  60633. */
  60634. get world(): NodeMaterialConnectionPoint;
  60635. /**
  60636. * Gets the output component
  60637. */
  60638. get output(): NodeMaterialConnectionPoint;
  60639. autoConfigure(material: NodeMaterial): void;
  60640. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60641. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60642. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60643. protected _buildBlock(state: NodeMaterialBuildState): this;
  60644. }
  60645. }
  60646. declare module BABYLON {
  60647. /**
  60648. * Block used to add support for instances
  60649. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60650. */
  60651. export class InstancesBlock extends NodeMaterialBlock {
  60652. /**
  60653. * Creates a new InstancesBlock
  60654. * @param name defines the block name
  60655. */
  60656. constructor(name: string);
  60657. /**
  60658. * Gets the current class name
  60659. * @returns the class name
  60660. */
  60661. getClassName(): string;
  60662. /**
  60663. * Gets the first world row input component
  60664. */
  60665. get world0(): NodeMaterialConnectionPoint;
  60666. /**
  60667. * Gets the second world row input component
  60668. */
  60669. get world1(): NodeMaterialConnectionPoint;
  60670. /**
  60671. * Gets the third world row input component
  60672. */
  60673. get world2(): NodeMaterialConnectionPoint;
  60674. /**
  60675. * Gets the forth world row input component
  60676. */
  60677. get world3(): NodeMaterialConnectionPoint;
  60678. /**
  60679. * Gets the world input component
  60680. */
  60681. get world(): NodeMaterialConnectionPoint;
  60682. /**
  60683. * Gets the output component
  60684. */
  60685. get output(): NodeMaterialConnectionPoint;
  60686. /**
  60687. * Gets the isntanceID component
  60688. */
  60689. get instanceID(): NodeMaterialConnectionPoint;
  60690. autoConfigure(material: NodeMaterial): void;
  60691. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60692. protected _buildBlock(state: NodeMaterialBuildState): this;
  60693. }
  60694. }
  60695. declare module BABYLON {
  60696. /**
  60697. * Block used to add morph targets support to vertex shader
  60698. */
  60699. export class MorphTargetsBlock extends NodeMaterialBlock {
  60700. private _repeatableContentAnchor;
  60701. /**
  60702. * Create a new MorphTargetsBlock
  60703. * @param name defines the block name
  60704. */
  60705. constructor(name: string);
  60706. /**
  60707. * Gets the current class name
  60708. * @returns the class name
  60709. */
  60710. getClassName(): string;
  60711. /**
  60712. * Gets the position input component
  60713. */
  60714. get position(): NodeMaterialConnectionPoint;
  60715. /**
  60716. * Gets the normal input component
  60717. */
  60718. get normal(): NodeMaterialConnectionPoint;
  60719. /**
  60720. * Gets the tangent input component
  60721. */
  60722. get tangent(): NodeMaterialConnectionPoint;
  60723. /**
  60724. * Gets the tangent input component
  60725. */
  60726. get uv(): NodeMaterialConnectionPoint;
  60727. /**
  60728. * Gets the position output component
  60729. */
  60730. get positionOutput(): NodeMaterialConnectionPoint;
  60731. /**
  60732. * Gets the normal output component
  60733. */
  60734. get normalOutput(): NodeMaterialConnectionPoint;
  60735. /**
  60736. * Gets the tangent output component
  60737. */
  60738. get tangentOutput(): NodeMaterialConnectionPoint;
  60739. /**
  60740. * Gets the tangent output component
  60741. */
  60742. get uvOutput(): NodeMaterialConnectionPoint;
  60743. initialize(state: NodeMaterialBuildState): void;
  60744. autoConfigure(material: NodeMaterial): void;
  60745. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60746. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60747. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60748. protected _buildBlock(state: NodeMaterialBuildState): this;
  60749. }
  60750. }
  60751. declare module BABYLON {
  60752. /**
  60753. * Block used to get data information from a light
  60754. */
  60755. export class LightInformationBlock extends NodeMaterialBlock {
  60756. private _lightDataUniformName;
  60757. private _lightColorUniformName;
  60758. private _lightTypeDefineName;
  60759. /**
  60760. * Gets or sets the light associated with this block
  60761. */
  60762. light: Nullable<Light>;
  60763. /**
  60764. * Creates a new LightInformationBlock
  60765. * @param name defines the block name
  60766. */
  60767. constructor(name: string);
  60768. /**
  60769. * Gets the current class name
  60770. * @returns the class name
  60771. */
  60772. getClassName(): string;
  60773. /**
  60774. * Gets the world position input component
  60775. */
  60776. get worldPosition(): NodeMaterialConnectionPoint;
  60777. /**
  60778. * Gets the direction output component
  60779. */
  60780. get direction(): NodeMaterialConnectionPoint;
  60781. /**
  60782. * Gets the direction output component
  60783. */
  60784. get color(): NodeMaterialConnectionPoint;
  60785. /**
  60786. * Gets the direction output component
  60787. */
  60788. get intensity(): NodeMaterialConnectionPoint;
  60789. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60790. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60791. protected _buildBlock(state: NodeMaterialBuildState): this;
  60792. serialize(): any;
  60793. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60794. }
  60795. }
  60796. declare module BABYLON {
  60797. /**
  60798. * Block used to add image processing support to fragment shader
  60799. */
  60800. export class ImageProcessingBlock extends NodeMaterialBlock {
  60801. /**
  60802. * Create a new ImageProcessingBlock
  60803. * @param name defines the block name
  60804. */
  60805. constructor(name: string);
  60806. /**
  60807. * Gets the current class name
  60808. * @returns the class name
  60809. */
  60810. getClassName(): string;
  60811. /**
  60812. * Gets the color input component
  60813. */
  60814. get color(): NodeMaterialConnectionPoint;
  60815. /**
  60816. * Gets the output component
  60817. */
  60818. get output(): NodeMaterialConnectionPoint;
  60819. /**
  60820. * Initialize the block and prepare the context for build
  60821. * @param state defines the state that will be used for the build
  60822. */
  60823. initialize(state: NodeMaterialBuildState): void;
  60824. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  60825. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60826. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60827. protected _buildBlock(state: NodeMaterialBuildState): this;
  60828. }
  60829. }
  60830. declare module BABYLON {
  60831. /**
  60832. * Block used to pertub normals based on a normal map
  60833. */
  60834. export class PerturbNormalBlock extends NodeMaterialBlock {
  60835. private _tangentSpaceParameterName;
  60836. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60837. invertX: boolean;
  60838. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  60839. invertY: boolean;
  60840. /**
  60841. * Create a new PerturbNormalBlock
  60842. * @param name defines the block name
  60843. */
  60844. constructor(name: string);
  60845. /**
  60846. * Gets the current class name
  60847. * @returns the class name
  60848. */
  60849. getClassName(): string;
  60850. /**
  60851. * Gets the world position input component
  60852. */
  60853. get worldPosition(): NodeMaterialConnectionPoint;
  60854. /**
  60855. * Gets the world normal input component
  60856. */
  60857. get worldNormal(): NodeMaterialConnectionPoint;
  60858. /**
  60859. * Gets the world tangent input component
  60860. */
  60861. get worldTangent(): NodeMaterialConnectionPoint;
  60862. /**
  60863. * Gets the uv input component
  60864. */
  60865. get uv(): NodeMaterialConnectionPoint;
  60866. /**
  60867. * Gets the normal map color input component
  60868. */
  60869. get normalMapColor(): NodeMaterialConnectionPoint;
  60870. /**
  60871. * Gets the strength input component
  60872. */
  60873. get strength(): NodeMaterialConnectionPoint;
  60874. /**
  60875. * Gets the output component
  60876. */
  60877. get output(): NodeMaterialConnectionPoint;
  60878. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60879. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60880. autoConfigure(material: NodeMaterial): void;
  60881. protected _buildBlock(state: NodeMaterialBuildState): this;
  60882. protected _dumpPropertiesCode(): string;
  60883. serialize(): any;
  60884. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60885. }
  60886. }
  60887. declare module BABYLON {
  60888. /**
  60889. * Block used to discard a pixel if a value is smaller than a cutoff
  60890. */
  60891. export class DiscardBlock extends NodeMaterialBlock {
  60892. /**
  60893. * Create a new DiscardBlock
  60894. * @param name defines the block name
  60895. */
  60896. constructor(name: string);
  60897. /**
  60898. * Gets the current class name
  60899. * @returns the class name
  60900. */
  60901. getClassName(): string;
  60902. /**
  60903. * Gets the color input component
  60904. */
  60905. get value(): NodeMaterialConnectionPoint;
  60906. /**
  60907. * Gets the cutoff input component
  60908. */
  60909. get cutoff(): NodeMaterialConnectionPoint;
  60910. protected _buildBlock(state: NodeMaterialBuildState): this;
  60911. }
  60912. }
  60913. declare module BABYLON {
  60914. /**
  60915. * Block used to test if the fragment shader is front facing
  60916. */
  60917. export class FrontFacingBlock extends NodeMaterialBlock {
  60918. /**
  60919. * Creates a new FrontFacingBlock
  60920. * @param name defines the block name
  60921. */
  60922. constructor(name: string);
  60923. /**
  60924. * Gets the current class name
  60925. * @returns the class name
  60926. */
  60927. getClassName(): string;
  60928. /**
  60929. * Gets the output component
  60930. */
  60931. get output(): NodeMaterialConnectionPoint;
  60932. protected _buildBlock(state: NodeMaterialBuildState): this;
  60933. }
  60934. }
  60935. declare module BABYLON {
  60936. /**
  60937. * Block used to get the derivative value on x and y of a given input
  60938. */
  60939. export class DerivativeBlock extends NodeMaterialBlock {
  60940. /**
  60941. * Create a new DerivativeBlock
  60942. * @param name defines the block name
  60943. */
  60944. constructor(name: string);
  60945. /**
  60946. * Gets the current class name
  60947. * @returns the class name
  60948. */
  60949. getClassName(): string;
  60950. /**
  60951. * Gets the input component
  60952. */
  60953. get input(): NodeMaterialConnectionPoint;
  60954. /**
  60955. * Gets the derivative output on x
  60956. */
  60957. get dx(): NodeMaterialConnectionPoint;
  60958. /**
  60959. * Gets the derivative output on y
  60960. */
  60961. get dy(): NodeMaterialConnectionPoint;
  60962. protected _buildBlock(state: NodeMaterialBuildState): this;
  60963. }
  60964. }
  60965. declare module BABYLON {
  60966. /**
  60967. * Block used to add support for scene fog
  60968. */
  60969. export class FogBlock extends NodeMaterialBlock {
  60970. private _fogDistanceName;
  60971. private _fogParameters;
  60972. /**
  60973. * Create a new FogBlock
  60974. * @param name defines the block name
  60975. */
  60976. constructor(name: string);
  60977. /**
  60978. * Gets the current class name
  60979. * @returns the class name
  60980. */
  60981. getClassName(): string;
  60982. /**
  60983. * Gets the world position input component
  60984. */
  60985. get worldPosition(): NodeMaterialConnectionPoint;
  60986. /**
  60987. * Gets the view input component
  60988. */
  60989. get view(): NodeMaterialConnectionPoint;
  60990. /**
  60991. * Gets the color input component
  60992. */
  60993. get input(): NodeMaterialConnectionPoint;
  60994. /**
  60995. * Gets the fog color input component
  60996. */
  60997. get fogColor(): NodeMaterialConnectionPoint;
  60998. /**
  60999. * Gets the output component
  61000. */
  61001. get output(): NodeMaterialConnectionPoint;
  61002. autoConfigure(material: NodeMaterial): void;
  61003. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61004. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61005. protected _buildBlock(state: NodeMaterialBuildState): this;
  61006. }
  61007. }
  61008. declare module BABYLON {
  61009. /**
  61010. * Block used to add light in the fragment shader
  61011. */
  61012. export class LightBlock extends NodeMaterialBlock {
  61013. private _lightId;
  61014. /**
  61015. * Gets or sets the light associated with this block
  61016. */
  61017. light: Nullable<Light>;
  61018. /**
  61019. * Create a new LightBlock
  61020. * @param name defines the block name
  61021. */
  61022. constructor(name: string);
  61023. /**
  61024. * Gets the current class name
  61025. * @returns the class name
  61026. */
  61027. getClassName(): string;
  61028. /**
  61029. * Gets the world position input component
  61030. */
  61031. get worldPosition(): NodeMaterialConnectionPoint;
  61032. /**
  61033. * Gets the world normal input component
  61034. */
  61035. get worldNormal(): NodeMaterialConnectionPoint;
  61036. /**
  61037. * Gets the camera (or eye) position component
  61038. */
  61039. get cameraPosition(): NodeMaterialConnectionPoint;
  61040. /**
  61041. * Gets the glossiness component
  61042. */
  61043. get glossiness(): NodeMaterialConnectionPoint;
  61044. /**
  61045. * Gets the glossinness power component
  61046. */
  61047. get glossPower(): NodeMaterialConnectionPoint;
  61048. /**
  61049. * Gets the diffuse color component
  61050. */
  61051. get diffuseColor(): NodeMaterialConnectionPoint;
  61052. /**
  61053. * Gets the specular color component
  61054. */
  61055. get specularColor(): NodeMaterialConnectionPoint;
  61056. /**
  61057. * Gets the diffuse output component
  61058. */
  61059. get diffuseOutput(): NodeMaterialConnectionPoint;
  61060. /**
  61061. * Gets the specular output component
  61062. */
  61063. get specularOutput(): NodeMaterialConnectionPoint;
  61064. /**
  61065. * Gets the shadow output component
  61066. */
  61067. get shadow(): NodeMaterialConnectionPoint;
  61068. autoConfigure(material: NodeMaterial): void;
  61069. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61070. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61071. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61072. private _injectVertexCode;
  61073. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61074. serialize(): any;
  61075. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61076. }
  61077. }
  61078. declare module BABYLON {
  61079. /**
  61080. * Block used to read a reflection texture from a sampler
  61081. */
  61082. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61083. /**
  61084. * Create a new ReflectionTextureBlock
  61085. * @param name defines the block name
  61086. */
  61087. constructor(name: string);
  61088. /**
  61089. * Gets the current class name
  61090. * @returns the class name
  61091. */
  61092. getClassName(): string;
  61093. /**
  61094. * Gets the world position input component
  61095. */
  61096. get position(): NodeMaterialConnectionPoint;
  61097. /**
  61098. * Gets the world position input component
  61099. */
  61100. get worldPosition(): NodeMaterialConnectionPoint;
  61101. /**
  61102. * Gets the world normal input component
  61103. */
  61104. get worldNormal(): NodeMaterialConnectionPoint;
  61105. /**
  61106. * Gets the world input component
  61107. */
  61108. get world(): NodeMaterialConnectionPoint;
  61109. /**
  61110. * Gets the camera (or eye) position component
  61111. */
  61112. get cameraPosition(): NodeMaterialConnectionPoint;
  61113. /**
  61114. * Gets the view input component
  61115. */
  61116. get view(): NodeMaterialConnectionPoint;
  61117. /**
  61118. * Gets the rgb output component
  61119. */
  61120. get rgb(): NodeMaterialConnectionPoint;
  61121. /**
  61122. * Gets the r output component
  61123. */
  61124. get r(): NodeMaterialConnectionPoint;
  61125. /**
  61126. * Gets the g output component
  61127. */
  61128. get g(): NodeMaterialConnectionPoint;
  61129. /**
  61130. * Gets the b output component
  61131. */
  61132. get b(): NodeMaterialConnectionPoint;
  61133. autoConfigure(material: NodeMaterial): void;
  61134. protected _buildBlock(state: NodeMaterialBuildState): this;
  61135. }
  61136. }
  61137. declare module BABYLON {
  61138. /**
  61139. * Block used to add 2 vectors
  61140. */
  61141. export class AddBlock extends NodeMaterialBlock {
  61142. /**
  61143. * Creates a new AddBlock
  61144. * @param name defines the block name
  61145. */
  61146. constructor(name: string);
  61147. /**
  61148. * Gets the current class name
  61149. * @returns the class name
  61150. */
  61151. getClassName(): string;
  61152. /**
  61153. * Gets the left operand input component
  61154. */
  61155. get left(): NodeMaterialConnectionPoint;
  61156. /**
  61157. * Gets the right operand input component
  61158. */
  61159. get right(): NodeMaterialConnectionPoint;
  61160. /**
  61161. * Gets the output component
  61162. */
  61163. get output(): NodeMaterialConnectionPoint;
  61164. protected _buildBlock(state: NodeMaterialBuildState): this;
  61165. }
  61166. }
  61167. declare module BABYLON {
  61168. /**
  61169. * Block used to scale a vector by a float
  61170. */
  61171. export class ScaleBlock extends NodeMaterialBlock {
  61172. /**
  61173. * Creates a new ScaleBlock
  61174. * @param name defines the block name
  61175. */
  61176. constructor(name: string);
  61177. /**
  61178. * Gets the current class name
  61179. * @returns the class name
  61180. */
  61181. getClassName(): string;
  61182. /**
  61183. * Gets the input component
  61184. */
  61185. get input(): NodeMaterialConnectionPoint;
  61186. /**
  61187. * Gets the factor input component
  61188. */
  61189. get factor(): NodeMaterialConnectionPoint;
  61190. /**
  61191. * Gets the output component
  61192. */
  61193. get output(): NodeMaterialConnectionPoint;
  61194. protected _buildBlock(state: NodeMaterialBuildState): this;
  61195. }
  61196. }
  61197. declare module BABYLON {
  61198. /**
  61199. * Block used to clamp a float
  61200. */
  61201. export class ClampBlock extends NodeMaterialBlock {
  61202. /** Gets or sets the minimum range */
  61203. minimum: number;
  61204. /** Gets or sets the maximum range */
  61205. maximum: number;
  61206. /**
  61207. * Creates a new ClampBlock
  61208. * @param name defines the block name
  61209. */
  61210. constructor(name: string);
  61211. /**
  61212. * Gets the current class name
  61213. * @returns the class name
  61214. */
  61215. getClassName(): string;
  61216. /**
  61217. * Gets the value input component
  61218. */
  61219. get value(): NodeMaterialConnectionPoint;
  61220. /**
  61221. * Gets the output component
  61222. */
  61223. get output(): NodeMaterialConnectionPoint;
  61224. protected _buildBlock(state: NodeMaterialBuildState): this;
  61225. protected _dumpPropertiesCode(): string;
  61226. serialize(): any;
  61227. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61228. }
  61229. }
  61230. declare module BABYLON {
  61231. /**
  61232. * Block used to apply a cross product between 2 vectors
  61233. */
  61234. export class CrossBlock extends NodeMaterialBlock {
  61235. /**
  61236. * Creates a new CrossBlock
  61237. * @param name defines the block name
  61238. */
  61239. constructor(name: string);
  61240. /**
  61241. * Gets the current class name
  61242. * @returns the class name
  61243. */
  61244. getClassName(): string;
  61245. /**
  61246. * Gets the left operand input component
  61247. */
  61248. get left(): NodeMaterialConnectionPoint;
  61249. /**
  61250. * Gets the right operand input component
  61251. */
  61252. get right(): NodeMaterialConnectionPoint;
  61253. /**
  61254. * Gets the output component
  61255. */
  61256. get output(): NodeMaterialConnectionPoint;
  61257. protected _buildBlock(state: NodeMaterialBuildState): this;
  61258. }
  61259. }
  61260. declare module BABYLON {
  61261. /**
  61262. * Block used to apply a dot product between 2 vectors
  61263. */
  61264. export class DotBlock extends NodeMaterialBlock {
  61265. /**
  61266. * Creates a new DotBlock
  61267. * @param name defines the block name
  61268. */
  61269. constructor(name: string);
  61270. /**
  61271. * Gets the current class name
  61272. * @returns the class name
  61273. */
  61274. getClassName(): string;
  61275. /**
  61276. * Gets the left operand input component
  61277. */
  61278. get left(): NodeMaterialConnectionPoint;
  61279. /**
  61280. * Gets the right operand input component
  61281. */
  61282. get right(): NodeMaterialConnectionPoint;
  61283. /**
  61284. * Gets the output component
  61285. */
  61286. get output(): NodeMaterialConnectionPoint;
  61287. protected _buildBlock(state: NodeMaterialBuildState): this;
  61288. }
  61289. }
  61290. declare module BABYLON {
  61291. /**
  61292. * Block used to normalize a vector
  61293. */
  61294. export class NormalizeBlock extends NodeMaterialBlock {
  61295. /**
  61296. * Creates a new NormalizeBlock
  61297. * @param name defines the block name
  61298. */
  61299. constructor(name: string);
  61300. /**
  61301. * Gets the current class name
  61302. * @returns the class name
  61303. */
  61304. getClassName(): string;
  61305. /**
  61306. * Gets the input component
  61307. */
  61308. get input(): NodeMaterialConnectionPoint;
  61309. /**
  61310. * Gets the output component
  61311. */
  61312. get output(): NodeMaterialConnectionPoint;
  61313. protected _buildBlock(state: NodeMaterialBuildState): this;
  61314. }
  61315. }
  61316. declare module BABYLON {
  61317. /**
  61318. * Operations supported by the Trigonometry block
  61319. */
  61320. export enum TrigonometryBlockOperations {
  61321. /** Cos */
  61322. Cos = 0,
  61323. /** Sin */
  61324. Sin = 1,
  61325. /** Abs */
  61326. Abs = 2,
  61327. /** Exp */
  61328. Exp = 3,
  61329. /** Exp2 */
  61330. Exp2 = 4,
  61331. /** Round */
  61332. Round = 5,
  61333. /** Floor */
  61334. Floor = 6,
  61335. /** Ceiling */
  61336. Ceiling = 7,
  61337. /** Square root */
  61338. Sqrt = 8,
  61339. /** Log */
  61340. Log = 9,
  61341. /** Tangent */
  61342. Tan = 10,
  61343. /** Arc tangent */
  61344. ArcTan = 11,
  61345. /** Arc cosinus */
  61346. ArcCos = 12,
  61347. /** Arc sinus */
  61348. ArcSin = 13,
  61349. /** Fraction */
  61350. Fract = 14,
  61351. /** Sign */
  61352. Sign = 15,
  61353. /** To radians (from degrees) */
  61354. Radians = 16,
  61355. /** To degrees (from radians) */
  61356. Degrees = 17
  61357. }
  61358. /**
  61359. * Block used to apply trigonometry operation to floats
  61360. */
  61361. export class TrigonometryBlock extends NodeMaterialBlock {
  61362. /**
  61363. * Gets or sets the operation applied by the block
  61364. */
  61365. operation: TrigonometryBlockOperations;
  61366. /**
  61367. * Creates a new TrigonometryBlock
  61368. * @param name defines the block name
  61369. */
  61370. constructor(name: string);
  61371. /**
  61372. * Gets the current class name
  61373. * @returns the class name
  61374. */
  61375. getClassName(): string;
  61376. /**
  61377. * Gets the input component
  61378. */
  61379. get input(): NodeMaterialConnectionPoint;
  61380. /**
  61381. * Gets the output component
  61382. */
  61383. get output(): NodeMaterialConnectionPoint;
  61384. protected _buildBlock(state: NodeMaterialBuildState): this;
  61385. serialize(): any;
  61386. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61387. protected _dumpPropertiesCode(): string;
  61388. }
  61389. }
  61390. declare module BABYLON {
  61391. /**
  61392. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61393. */
  61394. export class ColorMergerBlock extends NodeMaterialBlock {
  61395. /**
  61396. * Create a new ColorMergerBlock
  61397. * @param name defines the block name
  61398. */
  61399. constructor(name: string);
  61400. /**
  61401. * Gets the current class name
  61402. * @returns the class name
  61403. */
  61404. getClassName(): string;
  61405. /**
  61406. * Gets the rgb component (input)
  61407. */
  61408. get rgbIn(): NodeMaterialConnectionPoint;
  61409. /**
  61410. * Gets the r component (input)
  61411. */
  61412. get r(): NodeMaterialConnectionPoint;
  61413. /**
  61414. * Gets the g component (input)
  61415. */
  61416. get g(): NodeMaterialConnectionPoint;
  61417. /**
  61418. * Gets the b component (input)
  61419. */
  61420. get b(): NodeMaterialConnectionPoint;
  61421. /**
  61422. * Gets the a component (input)
  61423. */
  61424. get a(): NodeMaterialConnectionPoint;
  61425. /**
  61426. * Gets the rgba component (output)
  61427. */
  61428. get rgba(): NodeMaterialConnectionPoint;
  61429. /**
  61430. * Gets the rgb component (output)
  61431. */
  61432. get rgbOut(): NodeMaterialConnectionPoint;
  61433. /**
  61434. * Gets the rgb component (output)
  61435. * @deprecated Please use rgbOut instead.
  61436. */
  61437. get rgb(): NodeMaterialConnectionPoint;
  61438. protected _buildBlock(state: NodeMaterialBuildState): this;
  61439. }
  61440. }
  61441. declare module BABYLON {
  61442. /**
  61443. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61444. */
  61445. export class VectorSplitterBlock extends NodeMaterialBlock {
  61446. /**
  61447. * Create a new VectorSplitterBlock
  61448. * @param name defines the block name
  61449. */
  61450. constructor(name: string);
  61451. /**
  61452. * Gets the current class name
  61453. * @returns the class name
  61454. */
  61455. getClassName(): string;
  61456. /**
  61457. * Gets the xyzw component (input)
  61458. */
  61459. get xyzw(): NodeMaterialConnectionPoint;
  61460. /**
  61461. * Gets the xyz component (input)
  61462. */
  61463. get xyzIn(): NodeMaterialConnectionPoint;
  61464. /**
  61465. * Gets the xy component (input)
  61466. */
  61467. get xyIn(): NodeMaterialConnectionPoint;
  61468. /**
  61469. * Gets the xyz component (output)
  61470. */
  61471. get xyzOut(): NodeMaterialConnectionPoint;
  61472. /**
  61473. * Gets the xy component (output)
  61474. */
  61475. get xyOut(): NodeMaterialConnectionPoint;
  61476. /**
  61477. * Gets the x component (output)
  61478. */
  61479. get x(): NodeMaterialConnectionPoint;
  61480. /**
  61481. * Gets the y component (output)
  61482. */
  61483. get y(): NodeMaterialConnectionPoint;
  61484. /**
  61485. * Gets the z component (output)
  61486. */
  61487. get z(): NodeMaterialConnectionPoint;
  61488. /**
  61489. * Gets the w component (output)
  61490. */
  61491. get w(): NodeMaterialConnectionPoint;
  61492. protected _inputRename(name: string): string;
  61493. protected _outputRename(name: string): string;
  61494. protected _buildBlock(state: NodeMaterialBuildState): this;
  61495. }
  61496. }
  61497. declare module BABYLON {
  61498. /**
  61499. * Block used to lerp between 2 values
  61500. */
  61501. export class LerpBlock extends NodeMaterialBlock {
  61502. /**
  61503. * Creates a new LerpBlock
  61504. * @param name defines the block name
  61505. */
  61506. constructor(name: string);
  61507. /**
  61508. * Gets the current class name
  61509. * @returns the class name
  61510. */
  61511. getClassName(): string;
  61512. /**
  61513. * Gets the left operand input component
  61514. */
  61515. get left(): NodeMaterialConnectionPoint;
  61516. /**
  61517. * Gets the right operand input component
  61518. */
  61519. get right(): NodeMaterialConnectionPoint;
  61520. /**
  61521. * Gets the gradient operand input component
  61522. */
  61523. get gradient(): NodeMaterialConnectionPoint;
  61524. /**
  61525. * Gets the output component
  61526. */
  61527. get output(): NodeMaterialConnectionPoint;
  61528. protected _buildBlock(state: NodeMaterialBuildState): this;
  61529. }
  61530. }
  61531. declare module BABYLON {
  61532. /**
  61533. * Block used to divide 2 vectors
  61534. */
  61535. export class DivideBlock extends NodeMaterialBlock {
  61536. /**
  61537. * Creates a new DivideBlock
  61538. * @param name defines the block name
  61539. */
  61540. constructor(name: string);
  61541. /**
  61542. * Gets the current class name
  61543. * @returns the class name
  61544. */
  61545. getClassName(): string;
  61546. /**
  61547. * Gets the left operand input component
  61548. */
  61549. get left(): NodeMaterialConnectionPoint;
  61550. /**
  61551. * Gets the right operand input component
  61552. */
  61553. get right(): NodeMaterialConnectionPoint;
  61554. /**
  61555. * Gets the output component
  61556. */
  61557. get output(): NodeMaterialConnectionPoint;
  61558. protected _buildBlock(state: NodeMaterialBuildState): this;
  61559. }
  61560. }
  61561. declare module BABYLON {
  61562. /**
  61563. * Block used to subtract 2 vectors
  61564. */
  61565. export class SubtractBlock extends NodeMaterialBlock {
  61566. /**
  61567. * Creates a new SubtractBlock
  61568. * @param name defines the block name
  61569. */
  61570. constructor(name: string);
  61571. /**
  61572. * Gets the current class name
  61573. * @returns the class name
  61574. */
  61575. getClassName(): string;
  61576. /**
  61577. * Gets the left operand input component
  61578. */
  61579. get left(): NodeMaterialConnectionPoint;
  61580. /**
  61581. * Gets the right operand input component
  61582. */
  61583. get right(): NodeMaterialConnectionPoint;
  61584. /**
  61585. * Gets the output component
  61586. */
  61587. get output(): NodeMaterialConnectionPoint;
  61588. protected _buildBlock(state: NodeMaterialBuildState): this;
  61589. }
  61590. }
  61591. declare module BABYLON {
  61592. /**
  61593. * Block used to step a value
  61594. */
  61595. export class StepBlock extends NodeMaterialBlock {
  61596. /**
  61597. * Creates a new StepBlock
  61598. * @param name defines the block name
  61599. */
  61600. constructor(name: string);
  61601. /**
  61602. * Gets the current class name
  61603. * @returns the class name
  61604. */
  61605. getClassName(): string;
  61606. /**
  61607. * Gets the value operand input component
  61608. */
  61609. get value(): NodeMaterialConnectionPoint;
  61610. /**
  61611. * Gets the edge operand input component
  61612. */
  61613. get edge(): NodeMaterialConnectionPoint;
  61614. /**
  61615. * Gets the output component
  61616. */
  61617. get output(): NodeMaterialConnectionPoint;
  61618. protected _buildBlock(state: NodeMaterialBuildState): this;
  61619. }
  61620. }
  61621. declare module BABYLON {
  61622. /**
  61623. * Block used to get the opposite (1 - x) of a value
  61624. */
  61625. export class OneMinusBlock extends NodeMaterialBlock {
  61626. /**
  61627. * Creates a new OneMinusBlock
  61628. * @param name defines the block name
  61629. */
  61630. constructor(name: string);
  61631. /**
  61632. * Gets the current class name
  61633. * @returns the class name
  61634. */
  61635. getClassName(): string;
  61636. /**
  61637. * Gets the input component
  61638. */
  61639. get input(): NodeMaterialConnectionPoint;
  61640. /**
  61641. * Gets the output component
  61642. */
  61643. get output(): NodeMaterialConnectionPoint;
  61644. protected _buildBlock(state: NodeMaterialBuildState): this;
  61645. }
  61646. }
  61647. declare module BABYLON {
  61648. /**
  61649. * Block used to get the view direction
  61650. */
  61651. export class ViewDirectionBlock extends NodeMaterialBlock {
  61652. /**
  61653. * Creates a new ViewDirectionBlock
  61654. * @param name defines the block name
  61655. */
  61656. constructor(name: string);
  61657. /**
  61658. * Gets the current class name
  61659. * @returns the class name
  61660. */
  61661. getClassName(): string;
  61662. /**
  61663. * Gets the world position component
  61664. */
  61665. get worldPosition(): NodeMaterialConnectionPoint;
  61666. /**
  61667. * Gets the camera position component
  61668. */
  61669. get cameraPosition(): NodeMaterialConnectionPoint;
  61670. /**
  61671. * Gets the output component
  61672. */
  61673. get output(): NodeMaterialConnectionPoint;
  61674. autoConfigure(material: NodeMaterial): void;
  61675. protected _buildBlock(state: NodeMaterialBuildState): this;
  61676. }
  61677. }
  61678. declare module BABYLON {
  61679. /**
  61680. * Block used to compute fresnel value
  61681. */
  61682. export class FresnelBlock extends NodeMaterialBlock {
  61683. /**
  61684. * Create a new FresnelBlock
  61685. * @param name defines the block name
  61686. */
  61687. constructor(name: string);
  61688. /**
  61689. * Gets the current class name
  61690. * @returns the class name
  61691. */
  61692. getClassName(): string;
  61693. /**
  61694. * Gets the world normal input component
  61695. */
  61696. get worldNormal(): NodeMaterialConnectionPoint;
  61697. /**
  61698. * Gets the view direction input component
  61699. */
  61700. get viewDirection(): NodeMaterialConnectionPoint;
  61701. /**
  61702. * Gets the bias input component
  61703. */
  61704. get bias(): NodeMaterialConnectionPoint;
  61705. /**
  61706. * Gets the camera (or eye) position component
  61707. */
  61708. get power(): NodeMaterialConnectionPoint;
  61709. /**
  61710. * Gets the fresnel output component
  61711. */
  61712. get fresnel(): NodeMaterialConnectionPoint;
  61713. autoConfigure(material: NodeMaterial): void;
  61714. protected _buildBlock(state: NodeMaterialBuildState): this;
  61715. }
  61716. }
  61717. declare module BABYLON {
  61718. /**
  61719. * Block used to get the max of 2 values
  61720. */
  61721. export class MaxBlock extends NodeMaterialBlock {
  61722. /**
  61723. * Creates a new MaxBlock
  61724. * @param name defines the block name
  61725. */
  61726. constructor(name: string);
  61727. /**
  61728. * Gets the current class name
  61729. * @returns the class name
  61730. */
  61731. getClassName(): string;
  61732. /**
  61733. * Gets the left operand input component
  61734. */
  61735. get left(): NodeMaterialConnectionPoint;
  61736. /**
  61737. * Gets the right operand input component
  61738. */
  61739. get right(): NodeMaterialConnectionPoint;
  61740. /**
  61741. * Gets the output component
  61742. */
  61743. get output(): NodeMaterialConnectionPoint;
  61744. protected _buildBlock(state: NodeMaterialBuildState): this;
  61745. }
  61746. }
  61747. declare module BABYLON {
  61748. /**
  61749. * Block used to get the min of 2 values
  61750. */
  61751. export class MinBlock extends NodeMaterialBlock {
  61752. /**
  61753. * Creates a new MinBlock
  61754. * @param name defines the block name
  61755. */
  61756. constructor(name: string);
  61757. /**
  61758. * Gets the current class name
  61759. * @returns the class name
  61760. */
  61761. getClassName(): string;
  61762. /**
  61763. * Gets the left operand input component
  61764. */
  61765. get left(): NodeMaterialConnectionPoint;
  61766. /**
  61767. * Gets the right operand input component
  61768. */
  61769. get right(): NodeMaterialConnectionPoint;
  61770. /**
  61771. * Gets the output component
  61772. */
  61773. get output(): NodeMaterialConnectionPoint;
  61774. protected _buildBlock(state: NodeMaterialBuildState): this;
  61775. }
  61776. }
  61777. declare module BABYLON {
  61778. /**
  61779. * Block used to get the distance between 2 values
  61780. */
  61781. export class DistanceBlock extends NodeMaterialBlock {
  61782. /**
  61783. * Creates a new DistanceBlock
  61784. * @param name defines the block name
  61785. */
  61786. constructor(name: string);
  61787. /**
  61788. * Gets the current class name
  61789. * @returns the class name
  61790. */
  61791. getClassName(): string;
  61792. /**
  61793. * Gets the left operand input component
  61794. */
  61795. get left(): NodeMaterialConnectionPoint;
  61796. /**
  61797. * Gets the right operand input component
  61798. */
  61799. get right(): NodeMaterialConnectionPoint;
  61800. /**
  61801. * Gets the output component
  61802. */
  61803. get output(): NodeMaterialConnectionPoint;
  61804. protected _buildBlock(state: NodeMaterialBuildState): this;
  61805. }
  61806. }
  61807. declare module BABYLON {
  61808. /**
  61809. * Block used to get the length of a vector
  61810. */
  61811. export class LengthBlock extends NodeMaterialBlock {
  61812. /**
  61813. * Creates a new LengthBlock
  61814. * @param name defines the block name
  61815. */
  61816. constructor(name: string);
  61817. /**
  61818. * Gets the current class name
  61819. * @returns the class name
  61820. */
  61821. getClassName(): string;
  61822. /**
  61823. * Gets the value input component
  61824. */
  61825. get value(): NodeMaterialConnectionPoint;
  61826. /**
  61827. * Gets the output component
  61828. */
  61829. get output(): NodeMaterialConnectionPoint;
  61830. protected _buildBlock(state: NodeMaterialBuildState): this;
  61831. }
  61832. }
  61833. declare module BABYLON {
  61834. /**
  61835. * Block used to get negative version of a value (i.e. x * -1)
  61836. */
  61837. export class NegateBlock extends NodeMaterialBlock {
  61838. /**
  61839. * Creates a new NegateBlock
  61840. * @param name defines the block name
  61841. */
  61842. constructor(name: string);
  61843. /**
  61844. * Gets the current class name
  61845. * @returns the class name
  61846. */
  61847. getClassName(): string;
  61848. /**
  61849. * Gets the value input component
  61850. */
  61851. get value(): NodeMaterialConnectionPoint;
  61852. /**
  61853. * Gets the output component
  61854. */
  61855. get output(): NodeMaterialConnectionPoint;
  61856. protected _buildBlock(state: NodeMaterialBuildState): this;
  61857. }
  61858. }
  61859. declare module BABYLON {
  61860. /**
  61861. * Block used to get the value of the first parameter raised to the power of the second
  61862. */
  61863. export class PowBlock extends NodeMaterialBlock {
  61864. /**
  61865. * Creates a new PowBlock
  61866. * @param name defines the block name
  61867. */
  61868. constructor(name: string);
  61869. /**
  61870. * Gets the current class name
  61871. * @returns the class name
  61872. */
  61873. getClassName(): string;
  61874. /**
  61875. * Gets the value operand input component
  61876. */
  61877. get value(): NodeMaterialConnectionPoint;
  61878. /**
  61879. * Gets the power operand input component
  61880. */
  61881. get power(): NodeMaterialConnectionPoint;
  61882. /**
  61883. * Gets the output component
  61884. */
  61885. get output(): NodeMaterialConnectionPoint;
  61886. protected _buildBlock(state: NodeMaterialBuildState): this;
  61887. }
  61888. }
  61889. declare module BABYLON {
  61890. /**
  61891. * Block used to get a random number
  61892. */
  61893. export class RandomNumberBlock extends NodeMaterialBlock {
  61894. /**
  61895. * Creates a new RandomNumberBlock
  61896. * @param name defines the block name
  61897. */
  61898. constructor(name: string);
  61899. /**
  61900. * Gets the current class name
  61901. * @returns the class name
  61902. */
  61903. getClassName(): string;
  61904. /**
  61905. * Gets the seed input component
  61906. */
  61907. get seed(): NodeMaterialConnectionPoint;
  61908. /**
  61909. * Gets the output component
  61910. */
  61911. get output(): NodeMaterialConnectionPoint;
  61912. protected _buildBlock(state: NodeMaterialBuildState): this;
  61913. }
  61914. }
  61915. declare module BABYLON {
  61916. /**
  61917. * Block used to compute arc tangent of 2 values
  61918. */
  61919. export class ArcTan2Block extends NodeMaterialBlock {
  61920. /**
  61921. * Creates a new ArcTan2Block
  61922. * @param name defines the block name
  61923. */
  61924. constructor(name: string);
  61925. /**
  61926. * Gets the current class name
  61927. * @returns the class name
  61928. */
  61929. getClassName(): string;
  61930. /**
  61931. * Gets the x operand input component
  61932. */
  61933. get x(): NodeMaterialConnectionPoint;
  61934. /**
  61935. * Gets the y operand input component
  61936. */
  61937. get y(): NodeMaterialConnectionPoint;
  61938. /**
  61939. * Gets the output component
  61940. */
  61941. get output(): NodeMaterialConnectionPoint;
  61942. protected _buildBlock(state: NodeMaterialBuildState): this;
  61943. }
  61944. }
  61945. declare module BABYLON {
  61946. /**
  61947. * Block used to smooth step a value
  61948. */
  61949. export class SmoothStepBlock extends NodeMaterialBlock {
  61950. /**
  61951. * Creates a new SmoothStepBlock
  61952. * @param name defines the block name
  61953. */
  61954. constructor(name: string);
  61955. /**
  61956. * Gets the current class name
  61957. * @returns the class name
  61958. */
  61959. getClassName(): string;
  61960. /**
  61961. * Gets the value operand input component
  61962. */
  61963. get value(): NodeMaterialConnectionPoint;
  61964. /**
  61965. * Gets the first edge operand input component
  61966. */
  61967. get edge0(): NodeMaterialConnectionPoint;
  61968. /**
  61969. * Gets the second edge operand input component
  61970. */
  61971. get edge1(): NodeMaterialConnectionPoint;
  61972. /**
  61973. * Gets the output component
  61974. */
  61975. get output(): NodeMaterialConnectionPoint;
  61976. protected _buildBlock(state: NodeMaterialBuildState): this;
  61977. }
  61978. }
  61979. declare module BABYLON {
  61980. /**
  61981. * Block used to get the reciprocal (1 / x) of a value
  61982. */
  61983. export class ReciprocalBlock extends NodeMaterialBlock {
  61984. /**
  61985. * Creates a new ReciprocalBlock
  61986. * @param name defines the block name
  61987. */
  61988. constructor(name: string);
  61989. /**
  61990. * Gets the current class name
  61991. * @returns the class name
  61992. */
  61993. getClassName(): string;
  61994. /**
  61995. * Gets the input component
  61996. */
  61997. get input(): NodeMaterialConnectionPoint;
  61998. /**
  61999. * Gets the output component
  62000. */
  62001. get output(): NodeMaterialConnectionPoint;
  62002. protected _buildBlock(state: NodeMaterialBuildState): this;
  62003. }
  62004. }
  62005. declare module BABYLON {
  62006. /**
  62007. * Block used to replace a color by another one
  62008. */
  62009. export class ReplaceColorBlock extends NodeMaterialBlock {
  62010. /**
  62011. * Creates a new ReplaceColorBlock
  62012. * @param name defines the block name
  62013. */
  62014. constructor(name: string);
  62015. /**
  62016. * Gets the current class name
  62017. * @returns the class name
  62018. */
  62019. getClassName(): string;
  62020. /**
  62021. * Gets the value input component
  62022. */
  62023. get value(): NodeMaterialConnectionPoint;
  62024. /**
  62025. * Gets the reference input component
  62026. */
  62027. get reference(): NodeMaterialConnectionPoint;
  62028. /**
  62029. * Gets the distance input component
  62030. */
  62031. get distance(): NodeMaterialConnectionPoint;
  62032. /**
  62033. * Gets the replacement input component
  62034. */
  62035. get replacement(): NodeMaterialConnectionPoint;
  62036. /**
  62037. * Gets the output component
  62038. */
  62039. get output(): NodeMaterialConnectionPoint;
  62040. protected _buildBlock(state: NodeMaterialBuildState): this;
  62041. }
  62042. }
  62043. declare module BABYLON {
  62044. /**
  62045. * Block used to posterize a value
  62046. * @see https://en.wikipedia.org/wiki/Posterization
  62047. */
  62048. export class PosterizeBlock extends NodeMaterialBlock {
  62049. /**
  62050. * Creates a new PosterizeBlock
  62051. * @param name defines the block name
  62052. */
  62053. constructor(name: string);
  62054. /**
  62055. * Gets the current class name
  62056. * @returns the class name
  62057. */
  62058. getClassName(): string;
  62059. /**
  62060. * Gets the value input component
  62061. */
  62062. get value(): NodeMaterialConnectionPoint;
  62063. /**
  62064. * Gets the steps input component
  62065. */
  62066. get steps(): NodeMaterialConnectionPoint;
  62067. /**
  62068. * Gets the output component
  62069. */
  62070. get output(): NodeMaterialConnectionPoint;
  62071. protected _buildBlock(state: NodeMaterialBuildState): this;
  62072. }
  62073. }
  62074. declare module BABYLON {
  62075. /**
  62076. * Operations supported by the Wave block
  62077. */
  62078. export enum WaveBlockKind {
  62079. /** SawTooth */
  62080. SawTooth = 0,
  62081. /** Square */
  62082. Square = 1,
  62083. /** Triangle */
  62084. Triangle = 2
  62085. }
  62086. /**
  62087. * Block used to apply wave operation to floats
  62088. */
  62089. export class WaveBlock extends NodeMaterialBlock {
  62090. /**
  62091. * Gets or sets the kibnd of wave to be applied by the block
  62092. */
  62093. kind: WaveBlockKind;
  62094. /**
  62095. * Creates a new WaveBlock
  62096. * @param name defines the block name
  62097. */
  62098. constructor(name: string);
  62099. /**
  62100. * Gets the current class name
  62101. * @returns the class name
  62102. */
  62103. getClassName(): string;
  62104. /**
  62105. * Gets the input component
  62106. */
  62107. get input(): NodeMaterialConnectionPoint;
  62108. /**
  62109. * Gets the output component
  62110. */
  62111. get output(): NodeMaterialConnectionPoint;
  62112. protected _buildBlock(state: NodeMaterialBuildState): this;
  62113. serialize(): any;
  62114. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62115. }
  62116. }
  62117. declare module BABYLON {
  62118. /**
  62119. * Class used to store a color step for the GradientBlock
  62120. */
  62121. export class GradientBlockColorStep {
  62122. /**
  62123. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62124. */
  62125. step: number;
  62126. /**
  62127. * Gets or sets the color associated with this step
  62128. */
  62129. color: Color3;
  62130. /**
  62131. * Creates a new GradientBlockColorStep
  62132. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62133. * @param color defines the color associated with this step
  62134. */
  62135. constructor(
  62136. /**
  62137. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62138. */
  62139. step: number,
  62140. /**
  62141. * Gets or sets the color associated with this step
  62142. */
  62143. color: Color3);
  62144. }
  62145. /**
  62146. * Block used to return a color from a gradient based on an input value between 0 and 1
  62147. */
  62148. export class GradientBlock extends NodeMaterialBlock {
  62149. /**
  62150. * Gets or sets the list of color steps
  62151. */
  62152. colorSteps: GradientBlockColorStep[];
  62153. /**
  62154. * Creates a new GradientBlock
  62155. * @param name defines the block name
  62156. */
  62157. constructor(name: string);
  62158. /**
  62159. * Gets the current class name
  62160. * @returns the class name
  62161. */
  62162. getClassName(): string;
  62163. /**
  62164. * Gets the gradient input component
  62165. */
  62166. get gradient(): NodeMaterialConnectionPoint;
  62167. /**
  62168. * Gets the output component
  62169. */
  62170. get output(): NodeMaterialConnectionPoint;
  62171. private _writeColorConstant;
  62172. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62173. serialize(): any;
  62174. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62175. protected _dumpPropertiesCode(): string;
  62176. }
  62177. }
  62178. declare module BABYLON {
  62179. /**
  62180. * Block used to normalize lerp between 2 values
  62181. */
  62182. export class NLerpBlock extends NodeMaterialBlock {
  62183. /**
  62184. * Creates a new NLerpBlock
  62185. * @param name defines the block name
  62186. */
  62187. constructor(name: string);
  62188. /**
  62189. * Gets the current class name
  62190. * @returns the class name
  62191. */
  62192. getClassName(): string;
  62193. /**
  62194. * Gets the left operand input component
  62195. */
  62196. get left(): NodeMaterialConnectionPoint;
  62197. /**
  62198. * Gets the right operand input component
  62199. */
  62200. get right(): NodeMaterialConnectionPoint;
  62201. /**
  62202. * Gets the gradient operand input component
  62203. */
  62204. get gradient(): NodeMaterialConnectionPoint;
  62205. /**
  62206. * Gets the output component
  62207. */
  62208. get output(): NodeMaterialConnectionPoint;
  62209. protected _buildBlock(state: NodeMaterialBuildState): this;
  62210. }
  62211. }
  62212. declare module BABYLON {
  62213. /**
  62214. * block used to Generate a Worley Noise 3D Noise Pattern
  62215. */
  62216. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62217. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62218. manhattanDistance: boolean;
  62219. /**
  62220. * Creates a new WorleyNoise3DBlock
  62221. * @param name defines the block name
  62222. */
  62223. constructor(name: string);
  62224. /**
  62225. * Gets the current class name
  62226. * @returns the class name
  62227. */
  62228. getClassName(): string;
  62229. /**
  62230. * Gets the seed input component
  62231. */
  62232. get seed(): NodeMaterialConnectionPoint;
  62233. /**
  62234. * Gets the jitter input component
  62235. */
  62236. get jitter(): NodeMaterialConnectionPoint;
  62237. /**
  62238. * Gets the output component
  62239. */
  62240. get output(): NodeMaterialConnectionPoint;
  62241. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62242. /**
  62243. * Exposes the properties to the UI?
  62244. */
  62245. protected _dumpPropertiesCode(): string;
  62246. /**
  62247. * Exposes the properties to the Seralize?
  62248. */
  62249. serialize(): any;
  62250. /**
  62251. * Exposes the properties to the deseralize?
  62252. */
  62253. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62254. }
  62255. }
  62256. declare module BABYLON {
  62257. /**
  62258. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62259. */
  62260. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62261. /**
  62262. * Creates a new SimplexPerlin3DBlock
  62263. * @param name defines the block name
  62264. */
  62265. constructor(name: string);
  62266. /**
  62267. * Gets the current class name
  62268. * @returns the class name
  62269. */
  62270. getClassName(): string;
  62271. /**
  62272. * Gets the seed operand input component
  62273. */
  62274. get seed(): NodeMaterialConnectionPoint;
  62275. /**
  62276. * Gets the output component
  62277. */
  62278. get output(): NodeMaterialConnectionPoint;
  62279. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62280. }
  62281. }
  62282. declare module BABYLON {
  62283. /**
  62284. * Block used to blend normals
  62285. */
  62286. export class NormalBlendBlock extends NodeMaterialBlock {
  62287. /**
  62288. * Creates a new NormalBlendBlock
  62289. * @param name defines the block name
  62290. */
  62291. constructor(name: string);
  62292. /**
  62293. * Gets the current class name
  62294. * @returns the class name
  62295. */
  62296. getClassName(): string;
  62297. /**
  62298. * Gets the first input component
  62299. */
  62300. get normalMap0(): NodeMaterialConnectionPoint;
  62301. /**
  62302. * Gets the second input component
  62303. */
  62304. get normalMap1(): NodeMaterialConnectionPoint;
  62305. /**
  62306. * Gets the output component
  62307. */
  62308. get output(): NodeMaterialConnectionPoint;
  62309. protected _buildBlock(state: NodeMaterialBuildState): this;
  62310. }
  62311. }
  62312. declare module BABYLON {
  62313. /**
  62314. * Block used to rotate a 2d vector by a given angle
  62315. */
  62316. export class Rotate2dBlock extends NodeMaterialBlock {
  62317. /**
  62318. * Creates a new Rotate2dBlock
  62319. * @param name defines the block name
  62320. */
  62321. constructor(name: string);
  62322. /**
  62323. * Gets the current class name
  62324. * @returns the class name
  62325. */
  62326. getClassName(): string;
  62327. /**
  62328. * Gets the input vector
  62329. */
  62330. get input(): NodeMaterialConnectionPoint;
  62331. /**
  62332. * Gets the input angle
  62333. */
  62334. get angle(): NodeMaterialConnectionPoint;
  62335. /**
  62336. * Gets the output component
  62337. */
  62338. get output(): NodeMaterialConnectionPoint;
  62339. autoConfigure(material: NodeMaterial): void;
  62340. protected _buildBlock(state: NodeMaterialBuildState): this;
  62341. }
  62342. }
  62343. declare module BABYLON {
  62344. /**
  62345. * Block used to get the reflected vector from a direction and a normal
  62346. */
  62347. export class ReflectBlock extends NodeMaterialBlock {
  62348. /**
  62349. * Creates a new ReflectBlock
  62350. * @param name defines the block name
  62351. */
  62352. constructor(name: string);
  62353. /**
  62354. * Gets the current class name
  62355. * @returns the class name
  62356. */
  62357. getClassName(): string;
  62358. /**
  62359. * Gets the incident component
  62360. */
  62361. get incident(): NodeMaterialConnectionPoint;
  62362. /**
  62363. * Gets the normal component
  62364. */
  62365. get normal(): NodeMaterialConnectionPoint;
  62366. /**
  62367. * Gets the output component
  62368. */
  62369. get output(): NodeMaterialConnectionPoint;
  62370. protected _buildBlock(state: NodeMaterialBuildState): this;
  62371. }
  62372. }
  62373. declare module BABYLON {
  62374. /**
  62375. * Block used to get the refracted vector from a direction and a normal
  62376. */
  62377. export class RefractBlock extends NodeMaterialBlock {
  62378. /**
  62379. * Creates a new RefractBlock
  62380. * @param name defines the block name
  62381. */
  62382. constructor(name: string);
  62383. /**
  62384. * Gets the current class name
  62385. * @returns the class name
  62386. */
  62387. getClassName(): string;
  62388. /**
  62389. * Gets the incident component
  62390. */
  62391. get incident(): NodeMaterialConnectionPoint;
  62392. /**
  62393. * Gets the normal component
  62394. */
  62395. get normal(): NodeMaterialConnectionPoint;
  62396. /**
  62397. * Gets the index of refraction component
  62398. */
  62399. get ior(): NodeMaterialConnectionPoint;
  62400. /**
  62401. * Gets the output component
  62402. */
  62403. get output(): NodeMaterialConnectionPoint;
  62404. protected _buildBlock(state: NodeMaterialBuildState): this;
  62405. }
  62406. }
  62407. declare module BABYLON {
  62408. /**
  62409. * Block used to desaturate a color
  62410. */
  62411. export class DesaturateBlock extends NodeMaterialBlock {
  62412. /**
  62413. * Creates a new DesaturateBlock
  62414. * @param name defines the block name
  62415. */
  62416. constructor(name: string);
  62417. /**
  62418. * Gets the current class name
  62419. * @returns the class name
  62420. */
  62421. getClassName(): string;
  62422. /**
  62423. * Gets the color operand input component
  62424. */
  62425. get color(): NodeMaterialConnectionPoint;
  62426. /**
  62427. * Gets the level operand input component
  62428. */
  62429. get level(): NodeMaterialConnectionPoint;
  62430. /**
  62431. * Gets the output component
  62432. */
  62433. get output(): NodeMaterialConnectionPoint;
  62434. protected _buildBlock(state: NodeMaterialBuildState): this;
  62435. }
  62436. }
  62437. declare module BABYLON {
  62438. /**
  62439. * Block used to implement the ambient occlusion module of the PBR material
  62440. */
  62441. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62442. /**
  62443. * Create a new AmbientOcclusionBlock
  62444. * @param name defines the block name
  62445. */
  62446. constructor(name: string);
  62447. /**
  62448. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62449. */
  62450. useAmbientInGrayScale: boolean;
  62451. /**
  62452. * Initialize the block and prepare the context for build
  62453. * @param state defines the state that will be used for the build
  62454. */
  62455. initialize(state: NodeMaterialBuildState): void;
  62456. /**
  62457. * Gets the current class name
  62458. * @returns the class name
  62459. */
  62460. getClassName(): string;
  62461. /**
  62462. * Gets the texture input component
  62463. */
  62464. get texture(): NodeMaterialConnectionPoint;
  62465. /**
  62466. * Gets the texture intensity component
  62467. */
  62468. get intensity(): NodeMaterialConnectionPoint;
  62469. /**
  62470. * Gets the direct light intensity input component
  62471. */
  62472. get directLightIntensity(): NodeMaterialConnectionPoint;
  62473. /**
  62474. * Gets the ambient occlusion object output component
  62475. */
  62476. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62477. /**
  62478. * Gets the main code of the block (fragment side)
  62479. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  62480. * @returns the shader code
  62481. */
  62482. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  62483. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62484. protected _buildBlock(state: NodeMaterialBuildState): this;
  62485. protected _dumpPropertiesCode(): string;
  62486. serialize(): any;
  62487. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62488. }
  62489. }
  62490. declare module BABYLON {
  62491. /**
  62492. * Block used to implement the reflection module of the PBR material
  62493. */
  62494. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  62495. /** @hidden */
  62496. _defineLODReflectionAlpha: string;
  62497. /** @hidden */
  62498. _defineLinearSpecularReflection: string;
  62499. private _vEnvironmentIrradianceName;
  62500. /** @hidden */
  62501. _vReflectionMicrosurfaceInfosName: string;
  62502. /** @hidden */
  62503. _vReflectionInfosName: string;
  62504. private _scene;
  62505. /**
  62506. * The three properties below are set by the main PBR block prior to calling methods of this class.
  62507. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62508. * It's less burden on the user side in the editor part.
  62509. */
  62510. /** @hidden */
  62511. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62512. /** @hidden */
  62513. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62514. /** @hidden */
  62515. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  62516. /**
  62517. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  62518. * diffuse part of the IBL.
  62519. */
  62520. useSphericalHarmonics: boolean;
  62521. /**
  62522. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  62523. */
  62524. forceIrradianceInFragment: boolean;
  62525. /**
  62526. * Create a new ReflectionBlock
  62527. * @param name defines the block name
  62528. */
  62529. constructor(name: string);
  62530. /**
  62531. * Gets the current class name
  62532. * @returns the class name
  62533. */
  62534. getClassName(): string;
  62535. /**
  62536. * Gets the position input component
  62537. */
  62538. get position(): NodeMaterialConnectionPoint;
  62539. /**
  62540. * Gets the world position input component
  62541. */
  62542. get worldPosition(): NodeMaterialConnectionPoint;
  62543. /**
  62544. * Gets the world normal input component
  62545. */
  62546. get worldNormal(): NodeMaterialConnectionPoint;
  62547. /**
  62548. * Gets the world input component
  62549. */
  62550. get world(): NodeMaterialConnectionPoint;
  62551. /**
  62552. * Gets the camera (or eye) position component
  62553. */
  62554. get cameraPosition(): NodeMaterialConnectionPoint;
  62555. /**
  62556. * Gets the view input component
  62557. */
  62558. get view(): NodeMaterialConnectionPoint;
  62559. /**
  62560. * Gets the color input component
  62561. */
  62562. get color(): NodeMaterialConnectionPoint;
  62563. /**
  62564. * Gets the reflection object output component
  62565. */
  62566. get reflection(): NodeMaterialConnectionPoint;
  62567. /**
  62568. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  62569. */
  62570. get hasTexture(): boolean;
  62571. /**
  62572. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  62573. */
  62574. get reflectionColor(): string;
  62575. protected _getTexture(): Nullable<BaseTexture>;
  62576. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62577. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62578. /**
  62579. * Gets the code to inject in the vertex shader
  62580. * @param state current state of the node material building
  62581. * @returns the shader code
  62582. */
  62583. handleVertexSide(state: NodeMaterialBuildState): string;
  62584. /**
  62585. * Gets the main code of the block (fragment side)
  62586. * @param state current state of the node material building
  62587. * @param normalVarName name of the existing variable corresponding to the normal
  62588. * @returns the shader code
  62589. */
  62590. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  62591. protected _buildBlock(state: NodeMaterialBuildState): this;
  62592. protected _dumpPropertiesCode(): string;
  62593. serialize(): any;
  62594. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62595. }
  62596. }
  62597. declare module BABYLON {
  62598. /**
  62599. * Block used to implement the sheen module of the PBR material
  62600. */
  62601. export class SheenBlock extends NodeMaterialBlock {
  62602. /**
  62603. * Create a new SheenBlock
  62604. * @param name defines the block name
  62605. */
  62606. constructor(name: string);
  62607. /**
  62608. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  62609. * It allows the strength of the sheen effect to not depend on the base color of the material,
  62610. * making it easier to setup and tweak the effect
  62611. */
  62612. albedoScaling: boolean;
  62613. /**
  62614. * Defines if the sheen is linked to the sheen color.
  62615. */
  62616. linkSheenWithAlbedo: boolean;
  62617. /**
  62618. * Initialize the block and prepare the context for build
  62619. * @param state defines the state that will be used for the build
  62620. */
  62621. initialize(state: NodeMaterialBuildState): void;
  62622. /**
  62623. * Gets the current class name
  62624. * @returns the class name
  62625. */
  62626. getClassName(): string;
  62627. /**
  62628. * Gets the intensity input component
  62629. */
  62630. get intensity(): NodeMaterialConnectionPoint;
  62631. /**
  62632. * Gets the color input component
  62633. */
  62634. get color(): NodeMaterialConnectionPoint;
  62635. /**
  62636. * Gets the roughness input component
  62637. */
  62638. get roughness(): NodeMaterialConnectionPoint;
  62639. /**
  62640. * Gets the texture input component
  62641. */
  62642. get texture(): NodeMaterialConnectionPoint;
  62643. /**
  62644. * Gets the sheen object output component
  62645. */
  62646. get sheen(): NodeMaterialConnectionPoint;
  62647. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62648. /**
  62649. * Gets the main code of the block (fragment side)
  62650. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62651. * @returns the shader code
  62652. */
  62653. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  62654. protected _buildBlock(state: NodeMaterialBuildState): this;
  62655. protected _dumpPropertiesCode(): string;
  62656. serialize(): any;
  62657. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62658. }
  62659. }
  62660. declare module BABYLON {
  62661. /**
  62662. * Block used to implement the reflectivity module of the PBR material
  62663. */
  62664. export class ReflectivityBlock extends NodeMaterialBlock {
  62665. /**
  62666. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  62667. */
  62668. useAmbientOcclusionFromMetallicTextureRed: boolean;
  62669. /**
  62670. * Specifies if the metallic texture contains the metallness information in its blue channel.
  62671. */
  62672. useMetallnessFromMetallicTextureBlue: boolean;
  62673. /**
  62674. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  62675. */
  62676. useRoughnessFromMetallicTextureAlpha: boolean;
  62677. /**
  62678. * Specifies if the metallic texture contains the roughness information in its green channel.
  62679. */
  62680. useRoughnessFromMetallicTextureGreen: boolean;
  62681. /**
  62682. * Create a new ReflectivityBlock
  62683. * @param name defines the block name
  62684. */
  62685. constructor(name: string);
  62686. /**
  62687. * Initialize the block and prepare the context for build
  62688. * @param state defines the state that will be used for the build
  62689. */
  62690. initialize(state: NodeMaterialBuildState): void;
  62691. /**
  62692. * Gets the current class name
  62693. * @returns the class name
  62694. */
  62695. getClassName(): string;
  62696. /**
  62697. * Gets the metallic input component
  62698. */
  62699. get metallic(): NodeMaterialConnectionPoint;
  62700. /**
  62701. * Gets the roughness input component
  62702. */
  62703. get roughness(): NodeMaterialConnectionPoint;
  62704. /**
  62705. * Gets the texture input component
  62706. */
  62707. get texture(): NodeMaterialConnectionPoint;
  62708. /**
  62709. * Gets the reflectivity object output component
  62710. */
  62711. get reflectivity(): NodeMaterialConnectionPoint;
  62712. /**
  62713. * Gets the main code of the block (fragment side)
  62714. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  62715. * @returns the shader code
  62716. */
  62717. getCode(aoIntensityVarName: string): string;
  62718. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62719. protected _buildBlock(state: NodeMaterialBuildState): this;
  62720. protected _dumpPropertiesCode(): string;
  62721. serialize(): any;
  62722. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62723. }
  62724. }
  62725. declare module BABYLON {
  62726. /**
  62727. * Block used to implement the anisotropy module of the PBR material
  62728. */
  62729. export class AnisotropyBlock extends NodeMaterialBlock {
  62730. /**
  62731. * The two properties below are set by the main PBR block prior to calling methods of this class.
  62732. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62733. * It's less burden on the user side in the editor part.
  62734. */
  62735. /** @hidden */
  62736. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62737. /** @hidden */
  62738. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62739. /**
  62740. * Create a new AnisotropyBlock
  62741. * @param name defines the block name
  62742. */
  62743. constructor(name: string);
  62744. /**
  62745. * Initialize the block and prepare the context for build
  62746. * @param state defines the state that will be used for the build
  62747. */
  62748. initialize(state: NodeMaterialBuildState): void;
  62749. /**
  62750. * Gets the current class name
  62751. * @returns the class name
  62752. */
  62753. getClassName(): string;
  62754. /**
  62755. * Gets the intensity input component
  62756. */
  62757. get intensity(): NodeMaterialConnectionPoint;
  62758. /**
  62759. * Gets the direction input component
  62760. */
  62761. get direction(): NodeMaterialConnectionPoint;
  62762. /**
  62763. * Gets the texture input component
  62764. */
  62765. get texture(): NodeMaterialConnectionPoint;
  62766. /**
  62767. * Gets the uv input component
  62768. */
  62769. get uv(): NodeMaterialConnectionPoint;
  62770. /**
  62771. * Gets the worldTangent input component
  62772. */
  62773. get worldTangent(): NodeMaterialConnectionPoint;
  62774. /**
  62775. * Gets the anisotropy object output component
  62776. */
  62777. get anisotropy(): NodeMaterialConnectionPoint;
  62778. private _generateTBNSpace;
  62779. /**
  62780. * Gets the main code of the block (fragment side)
  62781. * @param state current state of the node material building
  62782. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62783. * @returns the shader code
  62784. */
  62785. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  62786. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62787. protected _buildBlock(state: NodeMaterialBuildState): this;
  62788. }
  62789. }
  62790. declare module BABYLON {
  62791. /**
  62792. * Block used to implement the clear coat module of the PBR material
  62793. */
  62794. export class ClearCoatBlock extends NodeMaterialBlock {
  62795. private _scene;
  62796. /**
  62797. * Create a new ClearCoatBlock
  62798. * @param name defines the block name
  62799. */
  62800. constructor(name: string);
  62801. /**
  62802. * Initialize the block and prepare the context for build
  62803. * @param state defines the state that will be used for the build
  62804. */
  62805. initialize(state: NodeMaterialBuildState): void;
  62806. /**
  62807. * Gets the current class name
  62808. * @returns the class name
  62809. */
  62810. getClassName(): string;
  62811. /**
  62812. * Gets the intensity input component
  62813. */
  62814. get intensity(): NodeMaterialConnectionPoint;
  62815. /**
  62816. * Gets the roughness input component
  62817. */
  62818. get roughness(): NodeMaterialConnectionPoint;
  62819. /**
  62820. * Gets the ior input component
  62821. */
  62822. get ior(): NodeMaterialConnectionPoint;
  62823. /**
  62824. * Gets the texture input component
  62825. */
  62826. get texture(): NodeMaterialConnectionPoint;
  62827. /**
  62828. * Gets the bump texture input component
  62829. */
  62830. get bumpTexture(): NodeMaterialConnectionPoint;
  62831. /**
  62832. * Gets the uv input component
  62833. */
  62834. get uv(): NodeMaterialConnectionPoint;
  62835. /**
  62836. * Gets the tint color input component
  62837. */
  62838. get tintColor(): NodeMaterialConnectionPoint;
  62839. /**
  62840. * Gets the tint "at distance" input component
  62841. */
  62842. get tintAtDistance(): NodeMaterialConnectionPoint;
  62843. /**
  62844. * Gets the tint thickness input component
  62845. */
  62846. get tintThickness(): NodeMaterialConnectionPoint;
  62847. /**
  62848. * Gets the tint texture input component
  62849. */
  62850. get tintTexture(): NodeMaterialConnectionPoint;
  62851. /**
  62852. * Gets the world tangent input component
  62853. */
  62854. get worldTangent(): NodeMaterialConnectionPoint;
  62855. /**
  62856. * Gets the clear coat object output component
  62857. */
  62858. get clearcoat(): NodeMaterialConnectionPoint;
  62859. autoConfigure(material: NodeMaterial): void;
  62860. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62861. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62862. private _generateTBNSpace;
  62863. /**
  62864. * Gets the main code of the block (fragment side)
  62865. * @param state current state of the node material building
  62866. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  62867. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62868. * @param worldPosVarName name of the variable holding the world position
  62869. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62870. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  62871. * @param worldNormalVarName name of the variable holding the world normal
  62872. * @returns the shader code
  62873. */
  62874. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  62875. protected _buildBlock(state: NodeMaterialBuildState): this;
  62876. }
  62877. }
  62878. declare module BABYLON {
  62879. /**
  62880. * Block used to implement the sub surface module of the PBR material
  62881. */
  62882. export class SubSurfaceBlock extends NodeMaterialBlock {
  62883. /**
  62884. * Create a new SubSurfaceBlock
  62885. * @param name defines the block name
  62886. */
  62887. constructor(name: string);
  62888. /**
  62889. * Stores the intensity of the different subsurface effects in the thickness texture.
  62890. * * the green channel is the translucency intensity.
  62891. * * the blue channel is the scattering intensity.
  62892. * * the alpha channel is the refraction intensity.
  62893. */
  62894. useMaskFromThicknessTexture: boolean;
  62895. /**
  62896. * Initialize the block and prepare the context for build
  62897. * @param state defines the state that will be used for the build
  62898. */
  62899. initialize(state: NodeMaterialBuildState): void;
  62900. /**
  62901. * Gets the current class name
  62902. * @returns the class name
  62903. */
  62904. getClassName(): string;
  62905. /**
  62906. * Gets the min thickness input component
  62907. */
  62908. get minThickness(): NodeMaterialConnectionPoint;
  62909. /**
  62910. * Gets the max thickness input component
  62911. */
  62912. get maxThickness(): NodeMaterialConnectionPoint;
  62913. /**
  62914. * Gets the thickness texture component
  62915. */
  62916. get thicknessTexture(): NodeMaterialConnectionPoint;
  62917. /**
  62918. * Gets the tint color input component
  62919. */
  62920. get tintColor(): NodeMaterialConnectionPoint;
  62921. /**
  62922. * Gets the translucency intensity input component
  62923. */
  62924. get translucencyIntensity(): NodeMaterialConnectionPoint;
  62925. /**
  62926. * Gets the translucency diffusion distance input component
  62927. */
  62928. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  62929. /**
  62930. * Gets the refraction object parameters
  62931. */
  62932. get refraction(): NodeMaterialConnectionPoint;
  62933. /**
  62934. * Gets the sub surface object output component
  62935. */
  62936. get subsurface(): NodeMaterialConnectionPoint;
  62937. autoConfigure(material: NodeMaterial): void;
  62938. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62939. /**
  62940. * Gets the main code of the block (fragment side)
  62941. * @param state current state of the node material building
  62942. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  62943. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62944. * @param worldPosVarName name of the variable holding the world position
  62945. * @returns the shader code
  62946. */
  62947. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  62948. protected _buildBlock(state: NodeMaterialBuildState): this;
  62949. }
  62950. }
  62951. declare module BABYLON {
  62952. /**
  62953. * Block used to implement the PBR metallic/roughness model
  62954. */
  62955. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  62956. /**
  62957. * Gets or sets the light associated with this block
  62958. */
  62959. light: Nullable<Light>;
  62960. private _lightId;
  62961. private _scene;
  62962. private _environmentBRDFTexture;
  62963. private _environmentBrdfSamplerName;
  62964. private _vNormalWName;
  62965. private _invertNormalName;
  62966. /**
  62967. * Create a new ReflectionBlock
  62968. * @param name defines the block name
  62969. */
  62970. constructor(name: string);
  62971. /**
  62972. * Intensity of the direct lights e.g. the four lights available in your scene.
  62973. * This impacts both the direct diffuse and specular highlights.
  62974. */
  62975. directIntensity: number;
  62976. /**
  62977. * Intensity of the environment e.g. how much the environment will light the object
  62978. * either through harmonics for rough material or through the refelction for shiny ones.
  62979. */
  62980. environmentIntensity: number;
  62981. /**
  62982. * This is a special control allowing the reduction of the specular highlights coming from the
  62983. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  62984. */
  62985. specularIntensity: number;
  62986. /**
  62987. * Defines the falloff type used in this material.
  62988. * It by default is Physical.
  62989. */
  62990. lightFalloff: number;
  62991. /**
  62992. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  62993. */
  62994. useAlphaFromAlbedoTexture: boolean;
  62995. /**
  62996. * Specifies that alpha test should be used
  62997. */
  62998. useAlphaTest: boolean;
  62999. /**
  63000. * Defines the alpha limits in alpha test mode.
  63001. */
  63002. alphaTestCutoff: number;
  63003. /**
  63004. * Specifies that alpha blending should be used
  63005. */
  63006. useAlphaBlending: boolean;
  63007. /**
  63008. * Defines if the alpha value should be determined via the rgb values.
  63009. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63010. */
  63011. opacityRGB: boolean;
  63012. /**
  63013. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63014. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63015. */
  63016. useRadianceOverAlpha: boolean;
  63017. /**
  63018. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63019. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63020. */
  63021. useSpecularOverAlpha: boolean;
  63022. /**
  63023. * Enables specular anti aliasing in the PBR shader.
  63024. * It will both interacts on the Geometry for analytical and IBL lighting.
  63025. * It also prefilter the roughness map based on the bump values.
  63026. */
  63027. enableSpecularAntiAliasing: boolean;
  63028. /**
  63029. * Defines if the material uses energy conservation.
  63030. */
  63031. useEnergyConservation: boolean;
  63032. /**
  63033. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63034. * too much the area relying on ambient texture to define their ambient occlusion.
  63035. */
  63036. useRadianceOcclusion: boolean;
  63037. /**
  63038. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63039. * makes the reflect vector face the model (under horizon).
  63040. */
  63041. useHorizonOcclusion: boolean;
  63042. /**
  63043. * If set to true, no lighting calculations will be applied.
  63044. */
  63045. unlit: boolean;
  63046. /**
  63047. * Force normal to face away from face.
  63048. */
  63049. forceNormalForward: boolean;
  63050. /**
  63051. * Defines the material debug mode.
  63052. * It helps seeing only some components of the material while troubleshooting.
  63053. */
  63054. debugMode: number;
  63055. /**
  63056. * Specify from where on screen the debug mode should start.
  63057. * The value goes from -1 (full screen) to 1 (not visible)
  63058. * It helps with side by side comparison against the final render
  63059. * This defaults to 0
  63060. */
  63061. debugLimit: number;
  63062. /**
  63063. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63064. * You can use the factor to better multiply the final value.
  63065. */
  63066. debugFactor: number;
  63067. /**
  63068. * Initialize the block and prepare the context for build
  63069. * @param state defines the state that will be used for the build
  63070. */
  63071. initialize(state: NodeMaterialBuildState): void;
  63072. /**
  63073. * Gets the current class name
  63074. * @returns the class name
  63075. */
  63076. getClassName(): string;
  63077. /**
  63078. * Gets the world position input component
  63079. */
  63080. get worldPosition(): NodeMaterialConnectionPoint;
  63081. /**
  63082. * Gets the world normal input component
  63083. */
  63084. get worldNormal(): NodeMaterialConnectionPoint;
  63085. /**
  63086. * Gets the perturbed normal input component
  63087. */
  63088. get perturbedNormal(): NodeMaterialConnectionPoint;
  63089. /**
  63090. * Gets the camera position input component
  63091. */
  63092. get cameraPosition(): NodeMaterialConnectionPoint;
  63093. /**
  63094. * Gets the base color input component
  63095. */
  63096. get baseColor(): NodeMaterialConnectionPoint;
  63097. /**
  63098. * Gets the base texture input component
  63099. */
  63100. get baseTexture(): NodeMaterialConnectionPoint;
  63101. /**
  63102. * Gets the opacity texture input component
  63103. */
  63104. get opacityTexture(): NodeMaterialConnectionPoint;
  63105. /**
  63106. * Gets the ambient color input component
  63107. */
  63108. get ambientColor(): NodeMaterialConnectionPoint;
  63109. /**
  63110. * Gets the reflectivity object parameters
  63111. */
  63112. get reflectivity(): NodeMaterialConnectionPoint;
  63113. /**
  63114. * Gets the ambient occlusion object parameters
  63115. */
  63116. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63117. /**
  63118. * Gets the reflection object parameters
  63119. */
  63120. get reflection(): NodeMaterialConnectionPoint;
  63121. /**
  63122. * Gets the sheen object parameters
  63123. */
  63124. get sheen(): NodeMaterialConnectionPoint;
  63125. /**
  63126. * Gets the clear coat object parameters
  63127. */
  63128. get clearcoat(): NodeMaterialConnectionPoint;
  63129. /**
  63130. * Gets the sub surface object parameters
  63131. */
  63132. get subsurface(): NodeMaterialConnectionPoint;
  63133. /**
  63134. * Gets the anisotropy object parameters
  63135. */
  63136. get anisotropy(): NodeMaterialConnectionPoint;
  63137. /**
  63138. * Gets the ambient output component
  63139. */
  63140. get ambient(): NodeMaterialConnectionPoint;
  63141. /**
  63142. * Gets the diffuse output component
  63143. */
  63144. get diffuse(): NodeMaterialConnectionPoint;
  63145. /**
  63146. * Gets the specular output component
  63147. */
  63148. get specular(): NodeMaterialConnectionPoint;
  63149. /**
  63150. * Gets the sheen output component
  63151. */
  63152. get sheenDir(): NodeMaterialConnectionPoint;
  63153. /**
  63154. * Gets the clear coat output component
  63155. */
  63156. get clearcoatDir(): NodeMaterialConnectionPoint;
  63157. /**
  63158. * Gets the indirect diffuse output component
  63159. */
  63160. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63161. /**
  63162. * Gets the indirect specular output component
  63163. */
  63164. get specularIndirect(): NodeMaterialConnectionPoint;
  63165. /**
  63166. * Gets the indirect sheen output component
  63167. */
  63168. get sheenIndirect(): NodeMaterialConnectionPoint;
  63169. /**
  63170. * Gets the indirect clear coat output component
  63171. */
  63172. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63173. /**
  63174. * Gets the refraction output component
  63175. */
  63176. get refraction(): NodeMaterialConnectionPoint;
  63177. /**
  63178. * Gets the global lighting output component
  63179. */
  63180. get lighting(): NodeMaterialConnectionPoint;
  63181. /**
  63182. * Gets the shadow output component
  63183. */
  63184. get shadow(): NodeMaterialConnectionPoint;
  63185. /**
  63186. * Gets the alpha output component
  63187. */
  63188. get alpha(): NodeMaterialConnectionPoint;
  63189. autoConfigure(material: NodeMaterial): void;
  63190. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63191. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63192. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63193. private _injectVertexCode;
  63194. /**
  63195. * Gets the code corresponding to the albedo/opacity module
  63196. * @returns the shader code
  63197. */
  63198. getAlbedoOpacityCode(): string;
  63199. protected _buildBlock(state: NodeMaterialBuildState): this;
  63200. protected _dumpPropertiesCode(): string;
  63201. serialize(): any;
  63202. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63203. }
  63204. }
  63205. declare module BABYLON {
  63206. /**
  63207. * Block used to compute value of one parameter modulo another
  63208. */
  63209. export class ModBlock extends NodeMaterialBlock {
  63210. /**
  63211. * Creates a new ModBlock
  63212. * @param name defines the block name
  63213. */
  63214. constructor(name: string);
  63215. /**
  63216. * Gets the current class name
  63217. * @returns the class name
  63218. */
  63219. getClassName(): string;
  63220. /**
  63221. * Gets the left operand input component
  63222. */
  63223. get left(): NodeMaterialConnectionPoint;
  63224. /**
  63225. * Gets the right operand input component
  63226. */
  63227. get right(): NodeMaterialConnectionPoint;
  63228. /**
  63229. * Gets the output component
  63230. */
  63231. get output(): NodeMaterialConnectionPoint;
  63232. protected _buildBlock(state: NodeMaterialBuildState): this;
  63233. }
  63234. }
  63235. declare module BABYLON {
  63236. /**
  63237. * Helper class to push actions to a pool of workers.
  63238. */
  63239. export class WorkerPool implements IDisposable {
  63240. private _workerInfos;
  63241. private _pendingActions;
  63242. /**
  63243. * Constructor
  63244. * @param workers Array of workers to use for actions
  63245. */
  63246. constructor(workers: Array<Worker>);
  63247. /**
  63248. * Terminates all workers and clears any pending actions.
  63249. */
  63250. dispose(): void;
  63251. /**
  63252. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63253. * pended until a worker has completed its action.
  63254. * @param action The action to perform. Call onComplete when the action is complete.
  63255. */
  63256. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63257. private _execute;
  63258. }
  63259. }
  63260. declare module BABYLON {
  63261. /**
  63262. * Configuration for Draco compression
  63263. */
  63264. export interface IDracoCompressionConfiguration {
  63265. /**
  63266. * Configuration for the decoder.
  63267. */
  63268. decoder: {
  63269. /**
  63270. * The url to the WebAssembly module.
  63271. */
  63272. wasmUrl?: string;
  63273. /**
  63274. * The url to the WebAssembly binary.
  63275. */
  63276. wasmBinaryUrl?: string;
  63277. /**
  63278. * The url to the fallback JavaScript module.
  63279. */
  63280. fallbackUrl?: string;
  63281. };
  63282. }
  63283. /**
  63284. * Draco compression (https://google.github.io/draco/)
  63285. *
  63286. * This class wraps the Draco module.
  63287. *
  63288. * **Encoder**
  63289. *
  63290. * The encoder is not currently implemented.
  63291. *
  63292. * **Decoder**
  63293. *
  63294. * 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.
  63295. *
  63296. * To update the configuration, use the following code:
  63297. * ```javascript
  63298. * DracoCompression.Configuration = {
  63299. * decoder: {
  63300. * wasmUrl: "<url to the WebAssembly library>",
  63301. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63302. * fallbackUrl: "<url to the fallback JavaScript library>",
  63303. * }
  63304. * };
  63305. * ```
  63306. *
  63307. * 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.
  63308. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63309. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63310. *
  63311. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63312. * ```javascript
  63313. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63314. * ```
  63315. *
  63316. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63317. */
  63318. export class DracoCompression implements IDisposable {
  63319. private _workerPoolPromise?;
  63320. private _decoderModulePromise?;
  63321. /**
  63322. * The configuration. Defaults to the following urls:
  63323. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63324. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63325. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63326. */
  63327. static Configuration: IDracoCompressionConfiguration;
  63328. /**
  63329. * Returns true if the decoder configuration is available.
  63330. */
  63331. static get DecoderAvailable(): boolean;
  63332. /**
  63333. * Default number of workers to create when creating the draco compression object.
  63334. */
  63335. static DefaultNumWorkers: number;
  63336. private static GetDefaultNumWorkers;
  63337. private static _Default;
  63338. /**
  63339. * Default instance for the draco compression object.
  63340. */
  63341. static get Default(): DracoCompression;
  63342. /**
  63343. * Constructor
  63344. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63345. */
  63346. constructor(numWorkers?: number);
  63347. /**
  63348. * Stop all async operations and release resources.
  63349. */
  63350. dispose(): void;
  63351. /**
  63352. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63353. * @returns a promise that resolves when ready
  63354. */
  63355. whenReadyAsync(): Promise<void>;
  63356. /**
  63357. * Decode Draco compressed mesh data to vertex data.
  63358. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63359. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63360. * @returns A promise that resolves with the decoded vertex data
  63361. */
  63362. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63363. [kind: string]: number;
  63364. }): Promise<VertexData>;
  63365. }
  63366. }
  63367. declare module BABYLON {
  63368. /**
  63369. * Class for building Constructive Solid Geometry
  63370. */
  63371. export class CSG {
  63372. private polygons;
  63373. /**
  63374. * The world matrix
  63375. */
  63376. matrix: Matrix;
  63377. /**
  63378. * Stores the position
  63379. */
  63380. position: Vector3;
  63381. /**
  63382. * Stores the rotation
  63383. */
  63384. rotation: Vector3;
  63385. /**
  63386. * Stores the rotation quaternion
  63387. */
  63388. rotationQuaternion: Nullable<Quaternion>;
  63389. /**
  63390. * Stores the scaling vector
  63391. */
  63392. scaling: Vector3;
  63393. /**
  63394. * Convert the Mesh to CSG
  63395. * @param mesh The Mesh to convert to CSG
  63396. * @returns A new CSG from the Mesh
  63397. */
  63398. static FromMesh(mesh: Mesh): CSG;
  63399. /**
  63400. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63401. * @param polygons Polygons used to construct a CSG solid
  63402. */
  63403. private static FromPolygons;
  63404. /**
  63405. * Clones, or makes a deep copy, of the CSG
  63406. * @returns A new CSG
  63407. */
  63408. clone(): CSG;
  63409. /**
  63410. * Unions this CSG with another CSG
  63411. * @param csg The CSG to union against this CSG
  63412. * @returns The unioned CSG
  63413. */
  63414. union(csg: CSG): CSG;
  63415. /**
  63416. * Unions this CSG with another CSG in place
  63417. * @param csg The CSG to union against this CSG
  63418. */
  63419. unionInPlace(csg: CSG): void;
  63420. /**
  63421. * Subtracts this CSG with another CSG
  63422. * @param csg The CSG to subtract against this CSG
  63423. * @returns A new CSG
  63424. */
  63425. subtract(csg: CSG): CSG;
  63426. /**
  63427. * Subtracts this CSG with another CSG in place
  63428. * @param csg The CSG to subtact against this CSG
  63429. */
  63430. subtractInPlace(csg: CSG): void;
  63431. /**
  63432. * Intersect this CSG with another CSG
  63433. * @param csg The CSG to intersect against this CSG
  63434. * @returns A new CSG
  63435. */
  63436. intersect(csg: CSG): CSG;
  63437. /**
  63438. * Intersects this CSG with another CSG in place
  63439. * @param csg The CSG to intersect against this CSG
  63440. */
  63441. intersectInPlace(csg: CSG): void;
  63442. /**
  63443. * Return a new CSG solid with solid and empty space switched. This solid is
  63444. * not modified.
  63445. * @returns A new CSG solid with solid and empty space switched
  63446. */
  63447. inverse(): CSG;
  63448. /**
  63449. * Inverses the CSG in place
  63450. */
  63451. inverseInPlace(): void;
  63452. /**
  63453. * This is used to keep meshes transformations so they can be restored
  63454. * when we build back a Babylon Mesh
  63455. * NB : All CSG operations are performed in world coordinates
  63456. * @param csg The CSG to copy the transform attributes from
  63457. * @returns This CSG
  63458. */
  63459. copyTransformAttributes(csg: CSG): CSG;
  63460. /**
  63461. * Build Raw mesh from CSG
  63462. * Coordinates here are in world space
  63463. * @param name The name of the mesh geometry
  63464. * @param scene The Scene
  63465. * @param keepSubMeshes Specifies if the submeshes should be kept
  63466. * @returns A new Mesh
  63467. */
  63468. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63469. /**
  63470. * Build Mesh from CSG taking material and transforms into account
  63471. * @param name The name of the Mesh
  63472. * @param material The material of the Mesh
  63473. * @param scene The Scene
  63474. * @param keepSubMeshes Specifies if submeshes should be kept
  63475. * @returns The new Mesh
  63476. */
  63477. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63478. }
  63479. }
  63480. declare module BABYLON {
  63481. /**
  63482. * Class used to create a trail following a mesh
  63483. */
  63484. export class TrailMesh extends Mesh {
  63485. private _generator;
  63486. private _autoStart;
  63487. private _running;
  63488. private _diameter;
  63489. private _length;
  63490. private _sectionPolygonPointsCount;
  63491. private _sectionVectors;
  63492. private _sectionNormalVectors;
  63493. private _beforeRenderObserver;
  63494. /**
  63495. * @constructor
  63496. * @param name The value used by scene.getMeshByName() to do a lookup.
  63497. * @param generator The mesh or transform node to generate a trail.
  63498. * @param scene The scene to add this mesh to.
  63499. * @param diameter Diameter of trailing mesh. Default is 1.
  63500. * @param length Length of trailing mesh. Default is 60.
  63501. * @param autoStart Automatically start trailing mesh. Default true.
  63502. */
  63503. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63504. /**
  63505. * "TrailMesh"
  63506. * @returns "TrailMesh"
  63507. */
  63508. getClassName(): string;
  63509. private _createMesh;
  63510. /**
  63511. * Start trailing mesh.
  63512. */
  63513. start(): void;
  63514. /**
  63515. * Stop trailing mesh.
  63516. */
  63517. stop(): void;
  63518. /**
  63519. * Update trailing mesh geometry.
  63520. */
  63521. update(): void;
  63522. /**
  63523. * Returns a new TrailMesh object.
  63524. * @param name is a string, the name given to the new mesh
  63525. * @param newGenerator use new generator object for cloned trail mesh
  63526. * @returns a new mesh
  63527. */
  63528. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63529. /**
  63530. * Serializes this trail mesh
  63531. * @param serializationObject object to write serialization to
  63532. */
  63533. serialize(serializationObject: any): void;
  63534. /**
  63535. * Parses a serialized trail mesh
  63536. * @param parsedMesh the serialized mesh
  63537. * @param scene the scene to create the trail mesh in
  63538. * @returns the created trail mesh
  63539. */
  63540. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63541. }
  63542. }
  63543. declare module BABYLON {
  63544. /**
  63545. * Class containing static functions to help procedurally build meshes
  63546. */
  63547. export class TiledBoxBuilder {
  63548. /**
  63549. * Creates a box mesh
  63550. * 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)
  63551. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63553. * * 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
  63554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63555. * @param name defines the name of the mesh
  63556. * @param options defines the options used to create the mesh
  63557. * @param scene defines the hosting scene
  63558. * @returns the box mesh
  63559. */
  63560. static CreateTiledBox(name: string, options: {
  63561. pattern?: number;
  63562. width?: number;
  63563. height?: number;
  63564. depth?: number;
  63565. tileSize?: number;
  63566. tileWidth?: number;
  63567. tileHeight?: number;
  63568. alignHorizontal?: number;
  63569. alignVertical?: number;
  63570. faceUV?: Vector4[];
  63571. faceColors?: Color4[];
  63572. sideOrientation?: number;
  63573. updatable?: boolean;
  63574. }, scene?: Nullable<Scene>): Mesh;
  63575. }
  63576. }
  63577. declare module BABYLON {
  63578. /**
  63579. * Class containing static functions to help procedurally build meshes
  63580. */
  63581. export class TorusKnotBuilder {
  63582. /**
  63583. * Creates a torus knot mesh
  63584. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63585. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63586. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63587. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63589. * * 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
  63590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63591. * @param name defines the name of the mesh
  63592. * @param options defines the options used to create the mesh
  63593. * @param scene defines the hosting scene
  63594. * @returns the torus knot mesh
  63595. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63596. */
  63597. static CreateTorusKnot(name: string, options: {
  63598. radius?: number;
  63599. tube?: number;
  63600. radialSegments?: number;
  63601. tubularSegments?: number;
  63602. p?: number;
  63603. q?: number;
  63604. updatable?: boolean;
  63605. sideOrientation?: number;
  63606. frontUVs?: Vector4;
  63607. backUVs?: Vector4;
  63608. }, scene: any): Mesh;
  63609. }
  63610. }
  63611. declare module BABYLON {
  63612. /**
  63613. * Polygon
  63614. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63615. */
  63616. export class Polygon {
  63617. /**
  63618. * Creates a rectangle
  63619. * @param xmin bottom X coord
  63620. * @param ymin bottom Y coord
  63621. * @param xmax top X coord
  63622. * @param ymax top Y coord
  63623. * @returns points that make the resulting rectation
  63624. */
  63625. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63626. /**
  63627. * Creates a circle
  63628. * @param radius radius of circle
  63629. * @param cx scale in x
  63630. * @param cy scale in y
  63631. * @param numberOfSides number of sides that make up the circle
  63632. * @returns points that make the resulting circle
  63633. */
  63634. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63635. /**
  63636. * Creates a polygon from input string
  63637. * @param input Input polygon data
  63638. * @returns the parsed points
  63639. */
  63640. static Parse(input: string): Vector2[];
  63641. /**
  63642. * Starts building a polygon from x and y coordinates
  63643. * @param x x coordinate
  63644. * @param y y coordinate
  63645. * @returns the started path2
  63646. */
  63647. static StartingAt(x: number, y: number): Path2;
  63648. }
  63649. /**
  63650. * Builds a polygon
  63651. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63652. */
  63653. export class PolygonMeshBuilder {
  63654. private _points;
  63655. private _outlinepoints;
  63656. private _holes;
  63657. private _name;
  63658. private _scene;
  63659. private _epoints;
  63660. private _eholes;
  63661. private _addToepoint;
  63662. /**
  63663. * Babylon reference to the earcut plugin.
  63664. */
  63665. bjsEarcut: any;
  63666. /**
  63667. * Creates a PolygonMeshBuilder
  63668. * @param name name of the builder
  63669. * @param contours Path of the polygon
  63670. * @param scene scene to add to when creating the mesh
  63671. * @param earcutInjection can be used to inject your own earcut reference
  63672. */
  63673. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63674. /**
  63675. * Adds a whole within the polygon
  63676. * @param hole Array of points defining the hole
  63677. * @returns this
  63678. */
  63679. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63680. /**
  63681. * Creates the polygon
  63682. * @param updatable If the mesh should be updatable
  63683. * @param depth The depth of the mesh created
  63684. * @returns the created mesh
  63685. */
  63686. build(updatable?: boolean, depth?: number): Mesh;
  63687. /**
  63688. * Creates the polygon
  63689. * @param depth The depth of the mesh created
  63690. * @returns the created VertexData
  63691. */
  63692. buildVertexData(depth?: number): VertexData;
  63693. /**
  63694. * Adds a side to the polygon
  63695. * @param positions points that make the polygon
  63696. * @param normals normals of the polygon
  63697. * @param uvs uvs of the polygon
  63698. * @param indices indices of the polygon
  63699. * @param bounds bounds of the polygon
  63700. * @param points points of the polygon
  63701. * @param depth depth of the polygon
  63702. * @param flip flip of the polygon
  63703. */
  63704. private addSide;
  63705. }
  63706. }
  63707. declare module BABYLON {
  63708. /**
  63709. * Class containing static functions to help procedurally build meshes
  63710. */
  63711. export class PolygonBuilder {
  63712. /**
  63713. * Creates a polygon mesh
  63714. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63715. * * 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
  63716. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63718. * * 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)
  63719. * * Remember you can only change the shape positions, not their number when updating a polygon
  63720. * @param name defines the name of the mesh
  63721. * @param options defines the options used to create the mesh
  63722. * @param scene defines the hosting scene
  63723. * @param earcutInjection can be used to inject your own earcut reference
  63724. * @returns the polygon mesh
  63725. */
  63726. static CreatePolygon(name: string, options: {
  63727. shape: Vector3[];
  63728. holes?: Vector3[][];
  63729. depth?: number;
  63730. faceUV?: Vector4[];
  63731. faceColors?: Color4[];
  63732. updatable?: boolean;
  63733. sideOrientation?: number;
  63734. frontUVs?: Vector4;
  63735. backUVs?: Vector4;
  63736. wrap?: boolean;
  63737. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63738. /**
  63739. * Creates an extruded polygon mesh, with depth in the Y direction.
  63740. * * 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)
  63741. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63742. * @param name defines the name of the mesh
  63743. * @param options defines the options used to create the mesh
  63744. * @param scene defines the hosting scene
  63745. * @param earcutInjection can be used to inject your own earcut reference
  63746. * @returns the polygon mesh
  63747. */
  63748. static ExtrudePolygon(name: string, options: {
  63749. shape: Vector3[];
  63750. holes?: Vector3[][];
  63751. depth?: number;
  63752. faceUV?: Vector4[];
  63753. faceColors?: Color4[];
  63754. updatable?: boolean;
  63755. sideOrientation?: number;
  63756. frontUVs?: Vector4;
  63757. backUVs?: Vector4;
  63758. wrap?: boolean;
  63759. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63760. }
  63761. }
  63762. declare module BABYLON {
  63763. /**
  63764. * Class containing static functions to help procedurally build meshes
  63765. */
  63766. export class LatheBuilder {
  63767. /**
  63768. * Creates lathe mesh.
  63769. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63770. * * 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
  63771. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63772. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63773. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63774. * * 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
  63775. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63776. * * 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
  63777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63778. * * 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
  63779. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63781. * @param name defines the name of the mesh
  63782. * @param options defines the options used to create the mesh
  63783. * @param scene defines the hosting scene
  63784. * @returns the lathe mesh
  63785. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63786. */
  63787. static CreateLathe(name: string, options: {
  63788. shape: Vector3[];
  63789. radius?: number;
  63790. tessellation?: number;
  63791. clip?: number;
  63792. arc?: number;
  63793. closed?: boolean;
  63794. updatable?: boolean;
  63795. sideOrientation?: number;
  63796. frontUVs?: Vector4;
  63797. backUVs?: Vector4;
  63798. cap?: number;
  63799. invertUV?: boolean;
  63800. }, scene?: Nullable<Scene>): Mesh;
  63801. }
  63802. }
  63803. declare module BABYLON {
  63804. /**
  63805. * Class containing static functions to help procedurally build meshes
  63806. */
  63807. export class TiledPlaneBuilder {
  63808. /**
  63809. * Creates a tiled plane mesh
  63810. * * The parameter `pattern` will, depending on value, do nothing or
  63811. * * * flip (reflect about central vertical) alternate tiles across and up
  63812. * * * flip every tile on alternate rows
  63813. * * * rotate (180 degs) alternate tiles across and up
  63814. * * * rotate every tile on alternate rows
  63815. * * * flip and rotate alternate tiles across and up
  63816. * * * flip and rotate every tile on alternate rows
  63817. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63818. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63819. * * 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
  63820. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63821. * * 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)
  63822. * * 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)
  63823. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63824. * @param name defines the name of the mesh
  63825. * @param options defines the options used to create the mesh
  63826. * @param scene defines the hosting scene
  63827. * @returns the box mesh
  63828. */
  63829. static CreateTiledPlane(name: string, options: {
  63830. pattern?: number;
  63831. tileSize?: number;
  63832. tileWidth?: number;
  63833. tileHeight?: number;
  63834. size?: number;
  63835. width?: number;
  63836. height?: number;
  63837. alignHorizontal?: number;
  63838. alignVertical?: number;
  63839. sideOrientation?: number;
  63840. frontUVs?: Vector4;
  63841. backUVs?: Vector4;
  63842. updatable?: boolean;
  63843. }, scene?: Nullable<Scene>): Mesh;
  63844. }
  63845. }
  63846. declare module BABYLON {
  63847. /**
  63848. * Class containing static functions to help procedurally build meshes
  63849. */
  63850. export class TubeBuilder {
  63851. /**
  63852. * Creates a tube mesh.
  63853. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63854. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63855. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63856. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63857. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63858. * * 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)
  63859. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63860. * * 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
  63861. * * 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
  63862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63863. * * 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
  63864. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63866. * @param name defines the name of the mesh
  63867. * @param options defines the options used to create the mesh
  63868. * @param scene defines the hosting scene
  63869. * @returns the tube mesh
  63870. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63871. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63872. */
  63873. static CreateTube(name: string, options: {
  63874. path: Vector3[];
  63875. radius?: number;
  63876. tessellation?: number;
  63877. radiusFunction?: {
  63878. (i: number, distance: number): number;
  63879. };
  63880. cap?: number;
  63881. arc?: number;
  63882. updatable?: boolean;
  63883. sideOrientation?: number;
  63884. frontUVs?: Vector4;
  63885. backUVs?: Vector4;
  63886. instance?: Mesh;
  63887. invertUV?: boolean;
  63888. }, scene?: Nullable<Scene>): Mesh;
  63889. }
  63890. }
  63891. declare module BABYLON {
  63892. /**
  63893. * Class containing static functions to help procedurally build meshes
  63894. */
  63895. export class IcoSphereBuilder {
  63896. /**
  63897. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63898. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63899. * * 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`)
  63900. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63901. * * 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
  63902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63903. * * 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
  63904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63905. * @param name defines the name of the mesh
  63906. * @param options defines the options used to create the mesh
  63907. * @param scene defines the hosting scene
  63908. * @returns the icosahedron mesh
  63909. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63910. */
  63911. static CreateIcoSphere(name: string, options: {
  63912. radius?: number;
  63913. radiusX?: number;
  63914. radiusY?: number;
  63915. radiusZ?: number;
  63916. flat?: boolean;
  63917. subdivisions?: number;
  63918. sideOrientation?: number;
  63919. frontUVs?: Vector4;
  63920. backUVs?: Vector4;
  63921. updatable?: boolean;
  63922. }, scene?: Nullable<Scene>): Mesh;
  63923. }
  63924. }
  63925. declare module BABYLON {
  63926. /**
  63927. * Class containing static functions to help procedurally build meshes
  63928. */
  63929. export class DecalBuilder {
  63930. /**
  63931. * Creates a decal mesh.
  63932. * 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
  63933. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63934. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63935. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63936. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63937. * @param name defines the name of the mesh
  63938. * @param sourceMesh defines the mesh where the decal must be applied
  63939. * @param options defines the options used to create the mesh
  63940. * @param scene defines the hosting scene
  63941. * @returns the decal mesh
  63942. * @see https://doc.babylonjs.com/how_to/decals
  63943. */
  63944. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63945. position?: Vector3;
  63946. normal?: Vector3;
  63947. size?: Vector3;
  63948. angle?: number;
  63949. }): Mesh;
  63950. }
  63951. }
  63952. declare module BABYLON {
  63953. /**
  63954. * Class containing static functions to help procedurally build meshes
  63955. */
  63956. export class MeshBuilder {
  63957. /**
  63958. * Creates a box mesh
  63959. * * The parameter `size` sets the size (float) of each box side (default 1)
  63960. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63961. * * 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)
  63962. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63964. * * 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
  63965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63966. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63967. * @param name defines the name of the mesh
  63968. * @param options defines the options used to create the mesh
  63969. * @param scene defines the hosting scene
  63970. * @returns the box mesh
  63971. */
  63972. static CreateBox(name: string, options: {
  63973. size?: number;
  63974. width?: number;
  63975. height?: number;
  63976. depth?: number;
  63977. faceUV?: Vector4[];
  63978. faceColors?: Color4[];
  63979. sideOrientation?: number;
  63980. frontUVs?: Vector4;
  63981. backUVs?: Vector4;
  63982. wrap?: boolean;
  63983. topBaseAt?: number;
  63984. bottomBaseAt?: number;
  63985. updatable?: boolean;
  63986. }, scene?: Nullable<Scene>): Mesh;
  63987. /**
  63988. * Creates a tiled box mesh
  63989. * * faceTiles sets the pattern, tile size and number of tiles for a face
  63990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63991. * @param name defines the name of the mesh
  63992. * @param options defines the options used to create the mesh
  63993. * @param scene defines the hosting scene
  63994. * @returns the tiled box mesh
  63995. */
  63996. static CreateTiledBox(name: string, options: {
  63997. pattern?: number;
  63998. size?: number;
  63999. width?: number;
  64000. height?: number;
  64001. depth: number;
  64002. tileSize?: number;
  64003. tileWidth?: number;
  64004. tileHeight?: number;
  64005. faceUV?: Vector4[];
  64006. faceColors?: Color4[];
  64007. alignHorizontal?: number;
  64008. alignVertical?: number;
  64009. sideOrientation?: number;
  64010. updatable?: boolean;
  64011. }, scene?: Nullable<Scene>): Mesh;
  64012. /**
  64013. * Creates a sphere mesh
  64014. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64015. * * 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`)
  64016. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64017. * * 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
  64018. * * 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)
  64019. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64020. * * 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
  64021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64022. * @param name defines the name of the mesh
  64023. * @param options defines the options used to create the mesh
  64024. * @param scene defines the hosting scene
  64025. * @returns the sphere mesh
  64026. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64027. */
  64028. static CreateSphere(name: string, options: {
  64029. segments?: number;
  64030. diameter?: number;
  64031. diameterX?: number;
  64032. diameterY?: number;
  64033. diameterZ?: number;
  64034. arc?: number;
  64035. slice?: number;
  64036. sideOrientation?: number;
  64037. frontUVs?: Vector4;
  64038. backUVs?: Vector4;
  64039. updatable?: boolean;
  64040. }, scene?: Nullable<Scene>): Mesh;
  64041. /**
  64042. * Creates a plane polygonal mesh. By default, this is a disc
  64043. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64044. * * 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
  64045. * * 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
  64046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64047. * * 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
  64048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64049. * @param name defines the name of the mesh
  64050. * @param options defines the options used to create the mesh
  64051. * @param scene defines the hosting scene
  64052. * @returns the plane polygonal mesh
  64053. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64054. */
  64055. static CreateDisc(name: string, options: {
  64056. radius?: number;
  64057. tessellation?: number;
  64058. arc?: number;
  64059. updatable?: boolean;
  64060. sideOrientation?: number;
  64061. frontUVs?: Vector4;
  64062. backUVs?: Vector4;
  64063. }, scene?: Nullable<Scene>): Mesh;
  64064. /**
  64065. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64066. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64067. * * 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`)
  64068. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64069. * * 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
  64070. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64071. * * 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
  64072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64073. * @param name defines the name of the mesh
  64074. * @param options defines the options used to create the mesh
  64075. * @param scene defines the hosting scene
  64076. * @returns the icosahedron mesh
  64077. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64078. */
  64079. static CreateIcoSphere(name: string, options: {
  64080. radius?: number;
  64081. radiusX?: number;
  64082. radiusY?: number;
  64083. radiusZ?: number;
  64084. flat?: boolean;
  64085. subdivisions?: number;
  64086. sideOrientation?: number;
  64087. frontUVs?: Vector4;
  64088. backUVs?: Vector4;
  64089. updatable?: boolean;
  64090. }, scene?: Nullable<Scene>): Mesh;
  64091. /**
  64092. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64093. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64094. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64095. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64096. * * 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
  64097. * * 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
  64098. * * 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
  64099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64101. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64102. * * 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
  64103. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64104. * * 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
  64105. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64107. * @param name defines the name of the mesh
  64108. * @param options defines the options used to create the mesh
  64109. * @param scene defines the hosting scene
  64110. * @returns the ribbon mesh
  64111. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64112. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64113. */
  64114. static CreateRibbon(name: string, options: {
  64115. pathArray: Vector3[][];
  64116. closeArray?: boolean;
  64117. closePath?: boolean;
  64118. offset?: number;
  64119. updatable?: boolean;
  64120. sideOrientation?: number;
  64121. frontUVs?: Vector4;
  64122. backUVs?: Vector4;
  64123. instance?: Mesh;
  64124. invertUV?: boolean;
  64125. uvs?: Vector2[];
  64126. colors?: Color4[];
  64127. }, scene?: Nullable<Scene>): Mesh;
  64128. /**
  64129. * Creates a cylinder or a cone mesh
  64130. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64131. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64132. * * 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.
  64133. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64134. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64135. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64136. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64137. * * 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).
  64138. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64139. * * 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).
  64140. * * 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
  64141. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64142. * * 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
  64143. * * 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.
  64144. * * If `enclose` is false, a ring surface is one element.
  64145. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64146. * * 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
  64147. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64148. * * 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
  64149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64150. * @param name defines the name of the mesh
  64151. * @param options defines the options used to create the mesh
  64152. * @param scene defines the hosting scene
  64153. * @returns the cylinder mesh
  64154. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64155. */
  64156. static CreateCylinder(name: string, options: {
  64157. height?: number;
  64158. diameterTop?: number;
  64159. diameterBottom?: number;
  64160. diameter?: number;
  64161. tessellation?: number;
  64162. subdivisions?: number;
  64163. arc?: number;
  64164. faceColors?: Color4[];
  64165. faceUV?: Vector4[];
  64166. updatable?: boolean;
  64167. hasRings?: boolean;
  64168. enclose?: boolean;
  64169. cap?: number;
  64170. sideOrientation?: number;
  64171. frontUVs?: Vector4;
  64172. backUVs?: Vector4;
  64173. }, scene?: Nullable<Scene>): Mesh;
  64174. /**
  64175. * Creates a torus mesh
  64176. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64177. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64178. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64180. * * 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
  64181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64182. * @param name defines the name of the mesh
  64183. * @param options defines the options used to create the mesh
  64184. * @param scene defines the hosting scene
  64185. * @returns the torus mesh
  64186. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64187. */
  64188. static CreateTorus(name: string, options: {
  64189. diameter?: number;
  64190. thickness?: number;
  64191. tessellation?: number;
  64192. updatable?: boolean;
  64193. sideOrientation?: number;
  64194. frontUVs?: Vector4;
  64195. backUVs?: Vector4;
  64196. }, scene?: Nullable<Scene>): Mesh;
  64197. /**
  64198. * Creates a torus knot mesh
  64199. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64200. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64201. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64202. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64204. * * 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
  64205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64206. * @param name defines the name of the mesh
  64207. * @param options defines the options used to create the mesh
  64208. * @param scene defines the hosting scene
  64209. * @returns the torus knot mesh
  64210. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64211. */
  64212. static CreateTorusKnot(name: string, options: {
  64213. radius?: number;
  64214. tube?: number;
  64215. radialSegments?: number;
  64216. tubularSegments?: number;
  64217. p?: number;
  64218. q?: number;
  64219. updatable?: boolean;
  64220. sideOrientation?: number;
  64221. frontUVs?: Vector4;
  64222. backUVs?: Vector4;
  64223. }, scene?: Nullable<Scene>): Mesh;
  64224. /**
  64225. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64226. * * 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
  64227. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64228. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64229. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64230. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64231. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64232. * * 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
  64233. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64235. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64236. * @param name defines the name of the new line system
  64237. * @param options defines the options used to create the line system
  64238. * @param scene defines the hosting scene
  64239. * @returns a new line system mesh
  64240. */
  64241. static CreateLineSystem(name: string, options: {
  64242. lines: Vector3[][];
  64243. updatable?: boolean;
  64244. instance?: Nullable<LinesMesh>;
  64245. colors?: Nullable<Color4[][]>;
  64246. useVertexAlpha?: boolean;
  64247. }, scene: Nullable<Scene>): LinesMesh;
  64248. /**
  64249. * Creates a line mesh
  64250. * 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
  64251. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64252. * * The parameter `points` is an array successive Vector3
  64253. * * 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
  64254. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64255. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64256. * * When updating an instance, remember that only point positions can change, not the number of points
  64257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64258. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64259. * @param name defines the name of the new line system
  64260. * @param options defines the options used to create the line system
  64261. * @param scene defines the hosting scene
  64262. * @returns a new line mesh
  64263. */
  64264. static CreateLines(name: string, options: {
  64265. points: Vector3[];
  64266. updatable?: boolean;
  64267. instance?: Nullable<LinesMesh>;
  64268. colors?: Color4[];
  64269. useVertexAlpha?: boolean;
  64270. }, scene?: Nullable<Scene>): LinesMesh;
  64271. /**
  64272. * Creates a dashed line mesh
  64273. * * 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
  64274. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64275. * * The parameter `points` is an array successive Vector3
  64276. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64277. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64278. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64279. * * 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
  64280. * * When updating an instance, remember that only point positions can change, not the number of points
  64281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64282. * @param name defines the name of the mesh
  64283. * @param options defines the options used to create the mesh
  64284. * @param scene defines the hosting scene
  64285. * @returns the dashed line mesh
  64286. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64287. */
  64288. static CreateDashedLines(name: string, options: {
  64289. points: Vector3[];
  64290. dashSize?: number;
  64291. gapSize?: number;
  64292. dashNb?: number;
  64293. updatable?: boolean;
  64294. instance?: LinesMesh;
  64295. }, scene?: Nullable<Scene>): LinesMesh;
  64296. /**
  64297. * 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.
  64298. * * 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.
  64299. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64300. * * 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.
  64301. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64302. * * 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
  64303. * * 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
  64304. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64306. * * 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
  64307. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64309. * @param name defines the name of the mesh
  64310. * @param options defines the options used to create the mesh
  64311. * @param scene defines the hosting scene
  64312. * @returns the extruded shape mesh
  64313. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64314. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64315. */
  64316. static ExtrudeShape(name: string, options: {
  64317. shape: Vector3[];
  64318. path: Vector3[];
  64319. scale?: number;
  64320. rotation?: number;
  64321. cap?: number;
  64322. updatable?: boolean;
  64323. sideOrientation?: number;
  64324. frontUVs?: Vector4;
  64325. backUVs?: Vector4;
  64326. instance?: Mesh;
  64327. invertUV?: boolean;
  64328. }, scene?: Nullable<Scene>): Mesh;
  64329. /**
  64330. * Creates an custom extruded shape mesh.
  64331. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64332. * * 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.
  64333. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64334. * * 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
  64335. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64336. * * 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
  64337. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64338. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64339. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64340. * * 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
  64341. * * 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
  64342. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64344. * * 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
  64345. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64347. * @param name defines the name of the mesh
  64348. * @param options defines the options used to create the mesh
  64349. * @param scene defines the hosting scene
  64350. * @returns the custom extruded shape mesh
  64351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64352. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64353. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64354. */
  64355. static ExtrudeShapeCustom(name: string, options: {
  64356. shape: Vector3[];
  64357. path: Vector3[];
  64358. scaleFunction?: any;
  64359. rotationFunction?: any;
  64360. ribbonCloseArray?: boolean;
  64361. ribbonClosePath?: boolean;
  64362. cap?: number;
  64363. updatable?: boolean;
  64364. sideOrientation?: number;
  64365. frontUVs?: Vector4;
  64366. backUVs?: Vector4;
  64367. instance?: Mesh;
  64368. invertUV?: boolean;
  64369. }, scene?: Nullable<Scene>): Mesh;
  64370. /**
  64371. * Creates lathe mesh.
  64372. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64373. * * 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
  64374. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64375. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64376. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64377. * * 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
  64378. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64379. * * 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
  64380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64381. * * 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
  64382. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64384. * @param name defines the name of the mesh
  64385. * @param options defines the options used to create the mesh
  64386. * @param scene defines the hosting scene
  64387. * @returns the lathe mesh
  64388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64389. */
  64390. static CreateLathe(name: string, options: {
  64391. shape: Vector3[];
  64392. radius?: number;
  64393. tessellation?: number;
  64394. clip?: number;
  64395. arc?: number;
  64396. closed?: boolean;
  64397. updatable?: boolean;
  64398. sideOrientation?: number;
  64399. frontUVs?: Vector4;
  64400. backUVs?: Vector4;
  64401. cap?: number;
  64402. invertUV?: boolean;
  64403. }, scene?: Nullable<Scene>): Mesh;
  64404. /**
  64405. * Creates a tiled plane mesh
  64406. * * You can set a limited pattern arrangement with the tiles
  64407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64408. * * 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
  64409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64410. * @param name defines the name of the mesh
  64411. * @param options defines the options used to create the mesh
  64412. * @param scene defines the hosting scene
  64413. * @returns the plane mesh
  64414. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64415. */
  64416. static CreateTiledPlane(name: string, options: {
  64417. pattern?: number;
  64418. tileSize?: number;
  64419. tileWidth?: number;
  64420. tileHeight?: number;
  64421. size?: number;
  64422. width?: number;
  64423. height?: number;
  64424. alignHorizontal?: number;
  64425. alignVertical?: number;
  64426. sideOrientation?: number;
  64427. frontUVs?: Vector4;
  64428. backUVs?: Vector4;
  64429. updatable?: boolean;
  64430. }, scene?: Nullable<Scene>): Mesh;
  64431. /**
  64432. * Creates a plane mesh
  64433. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64434. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64435. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64437. * * 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
  64438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64439. * @param name defines the name of the mesh
  64440. * @param options defines the options used to create the mesh
  64441. * @param scene defines the hosting scene
  64442. * @returns the plane mesh
  64443. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64444. */
  64445. static CreatePlane(name: string, options: {
  64446. size?: number;
  64447. width?: number;
  64448. height?: number;
  64449. sideOrientation?: number;
  64450. frontUVs?: Vector4;
  64451. backUVs?: Vector4;
  64452. updatable?: boolean;
  64453. sourcePlane?: Plane;
  64454. }, scene?: Nullable<Scene>): Mesh;
  64455. /**
  64456. * Creates a ground mesh
  64457. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64458. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64460. * @param name defines the name of the mesh
  64461. * @param options defines the options used to create the mesh
  64462. * @param scene defines the hosting scene
  64463. * @returns the ground mesh
  64464. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64465. */
  64466. static CreateGround(name: string, options: {
  64467. width?: number;
  64468. height?: number;
  64469. subdivisions?: number;
  64470. subdivisionsX?: number;
  64471. subdivisionsY?: number;
  64472. updatable?: boolean;
  64473. }, scene?: Nullable<Scene>): Mesh;
  64474. /**
  64475. * Creates a tiled ground mesh
  64476. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64477. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64478. * * 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
  64479. * * 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
  64480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64481. * @param name defines the name of the mesh
  64482. * @param options defines the options used to create the mesh
  64483. * @param scene defines the hosting scene
  64484. * @returns the tiled ground mesh
  64485. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64486. */
  64487. static CreateTiledGround(name: string, options: {
  64488. xmin: number;
  64489. zmin: number;
  64490. xmax: number;
  64491. zmax: number;
  64492. subdivisions?: {
  64493. w: number;
  64494. h: number;
  64495. };
  64496. precision?: {
  64497. w: number;
  64498. h: number;
  64499. };
  64500. updatable?: boolean;
  64501. }, scene?: Nullable<Scene>): Mesh;
  64502. /**
  64503. * Creates a ground mesh from a height map
  64504. * * The parameter `url` sets the URL of the height map image resource.
  64505. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64506. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64507. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64508. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64509. * * 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.
  64510. * * 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).
  64511. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64513. * @param name defines the name of the mesh
  64514. * @param url defines the url to the height map
  64515. * @param options defines the options used to create the mesh
  64516. * @param scene defines the hosting scene
  64517. * @returns the ground mesh
  64518. * @see https://doc.babylonjs.com/babylon101/height_map
  64519. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64520. */
  64521. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64522. width?: number;
  64523. height?: number;
  64524. subdivisions?: number;
  64525. minHeight?: number;
  64526. maxHeight?: number;
  64527. colorFilter?: Color3;
  64528. alphaFilter?: number;
  64529. updatable?: boolean;
  64530. onReady?: (mesh: GroundMesh) => void;
  64531. }, scene?: Nullable<Scene>): GroundMesh;
  64532. /**
  64533. * Creates a polygon mesh
  64534. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64535. * * 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
  64536. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64538. * * 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)
  64539. * * Remember you can only change the shape positions, not their number when updating a polygon
  64540. * @param name defines the name of the mesh
  64541. * @param options defines the options used to create the mesh
  64542. * @param scene defines the hosting scene
  64543. * @param earcutInjection can be used to inject your own earcut reference
  64544. * @returns the polygon mesh
  64545. */
  64546. static CreatePolygon(name: string, options: {
  64547. shape: Vector3[];
  64548. holes?: Vector3[][];
  64549. depth?: number;
  64550. faceUV?: Vector4[];
  64551. faceColors?: Color4[];
  64552. updatable?: boolean;
  64553. sideOrientation?: number;
  64554. frontUVs?: Vector4;
  64555. backUVs?: Vector4;
  64556. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64557. /**
  64558. * Creates an extruded polygon mesh, with depth in the Y direction.
  64559. * * 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)
  64560. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64561. * @param name defines the name of the mesh
  64562. * @param options defines the options used to create the mesh
  64563. * @param scene defines the hosting scene
  64564. * @param earcutInjection can be used to inject your own earcut reference
  64565. * @returns the polygon mesh
  64566. */
  64567. static ExtrudePolygon(name: string, options: {
  64568. shape: Vector3[];
  64569. holes?: Vector3[][];
  64570. depth?: number;
  64571. faceUV?: Vector4[];
  64572. faceColors?: Color4[];
  64573. updatable?: boolean;
  64574. sideOrientation?: number;
  64575. frontUVs?: Vector4;
  64576. backUVs?: Vector4;
  64577. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64578. /**
  64579. * Creates a tube mesh.
  64580. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64581. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64582. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64583. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64584. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64585. * * 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)
  64586. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64587. * * 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
  64588. * * 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
  64589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64590. * * 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
  64591. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64593. * @param name defines the name of the mesh
  64594. * @param options defines the options used to create the mesh
  64595. * @param scene defines the hosting scene
  64596. * @returns the tube mesh
  64597. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64598. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64599. */
  64600. static CreateTube(name: string, options: {
  64601. path: Vector3[];
  64602. radius?: number;
  64603. tessellation?: number;
  64604. radiusFunction?: {
  64605. (i: number, distance: number): number;
  64606. };
  64607. cap?: number;
  64608. arc?: number;
  64609. updatable?: boolean;
  64610. sideOrientation?: number;
  64611. frontUVs?: Vector4;
  64612. backUVs?: Vector4;
  64613. instance?: Mesh;
  64614. invertUV?: boolean;
  64615. }, scene?: Nullable<Scene>): Mesh;
  64616. /**
  64617. * Creates a polyhedron mesh
  64618. * * 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
  64619. * * The parameter `size` (positive float, default 1) sets the polygon size
  64620. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64621. * * 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`
  64622. * * 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
  64623. * * 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)`)
  64624. * * 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
  64625. * * 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
  64626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64627. * * 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
  64628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64629. * @param name defines the name of the mesh
  64630. * @param options defines the options used to create the mesh
  64631. * @param scene defines the hosting scene
  64632. * @returns the polyhedron mesh
  64633. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64634. */
  64635. static CreatePolyhedron(name: string, options: {
  64636. type?: number;
  64637. size?: number;
  64638. sizeX?: number;
  64639. sizeY?: number;
  64640. sizeZ?: number;
  64641. custom?: any;
  64642. faceUV?: Vector4[];
  64643. faceColors?: Color4[];
  64644. flat?: boolean;
  64645. updatable?: boolean;
  64646. sideOrientation?: number;
  64647. frontUVs?: Vector4;
  64648. backUVs?: Vector4;
  64649. }, scene?: Nullable<Scene>): Mesh;
  64650. /**
  64651. * Creates a decal mesh.
  64652. * 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
  64653. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64654. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64655. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64656. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64657. * @param name defines the name of the mesh
  64658. * @param sourceMesh defines the mesh where the decal must be applied
  64659. * @param options defines the options used to create the mesh
  64660. * @param scene defines the hosting scene
  64661. * @returns the decal mesh
  64662. * @see https://doc.babylonjs.com/how_to/decals
  64663. */
  64664. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64665. position?: Vector3;
  64666. normal?: Vector3;
  64667. size?: Vector3;
  64668. angle?: number;
  64669. }): Mesh;
  64670. }
  64671. }
  64672. declare module BABYLON {
  64673. /**
  64674. * A simplifier interface for future simplification implementations
  64675. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64676. */
  64677. export interface ISimplifier {
  64678. /**
  64679. * Simplification of a given mesh according to the given settings.
  64680. * Since this requires computation, it is assumed that the function runs async.
  64681. * @param settings The settings of the simplification, including quality and distance
  64682. * @param successCallback A callback that will be called after the mesh was simplified.
  64683. * @param errorCallback in case of an error, this callback will be called. optional.
  64684. */
  64685. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64686. }
  64687. /**
  64688. * Expected simplification settings.
  64689. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64690. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64691. */
  64692. export interface ISimplificationSettings {
  64693. /**
  64694. * Gets or sets the expected quality
  64695. */
  64696. quality: number;
  64697. /**
  64698. * Gets or sets the distance when this optimized version should be used
  64699. */
  64700. distance: number;
  64701. /**
  64702. * Gets an already optimized mesh
  64703. */
  64704. optimizeMesh?: boolean;
  64705. }
  64706. /**
  64707. * Class used to specify simplification options
  64708. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64709. */
  64710. export class SimplificationSettings implements ISimplificationSettings {
  64711. /** expected quality */
  64712. quality: number;
  64713. /** distance when this optimized version should be used */
  64714. distance: number;
  64715. /** already optimized mesh */
  64716. optimizeMesh?: boolean | undefined;
  64717. /**
  64718. * Creates a SimplificationSettings
  64719. * @param quality expected quality
  64720. * @param distance distance when this optimized version should be used
  64721. * @param optimizeMesh already optimized mesh
  64722. */
  64723. constructor(
  64724. /** expected quality */
  64725. quality: number,
  64726. /** distance when this optimized version should be used */
  64727. distance: number,
  64728. /** already optimized mesh */
  64729. optimizeMesh?: boolean | undefined);
  64730. }
  64731. /**
  64732. * Interface used to define a simplification task
  64733. */
  64734. export interface ISimplificationTask {
  64735. /**
  64736. * Array of settings
  64737. */
  64738. settings: Array<ISimplificationSettings>;
  64739. /**
  64740. * Simplification type
  64741. */
  64742. simplificationType: SimplificationType;
  64743. /**
  64744. * Mesh to simplify
  64745. */
  64746. mesh: Mesh;
  64747. /**
  64748. * Callback called on success
  64749. */
  64750. successCallback?: () => void;
  64751. /**
  64752. * Defines if parallel processing can be used
  64753. */
  64754. parallelProcessing: boolean;
  64755. }
  64756. /**
  64757. * Queue used to order the simplification tasks
  64758. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64759. */
  64760. export class SimplificationQueue {
  64761. private _simplificationArray;
  64762. /**
  64763. * Gets a boolean indicating that the process is still running
  64764. */
  64765. running: boolean;
  64766. /**
  64767. * Creates a new queue
  64768. */
  64769. constructor();
  64770. /**
  64771. * Adds a new simplification task
  64772. * @param task defines a task to add
  64773. */
  64774. addTask(task: ISimplificationTask): void;
  64775. /**
  64776. * Execute next task
  64777. */
  64778. executeNext(): void;
  64779. /**
  64780. * Execute a simplification task
  64781. * @param task defines the task to run
  64782. */
  64783. runSimplification(task: ISimplificationTask): void;
  64784. private getSimplifier;
  64785. }
  64786. /**
  64787. * The implemented types of simplification
  64788. * At the moment only Quadratic Error Decimation is implemented
  64789. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64790. */
  64791. export enum SimplificationType {
  64792. /** Quadratic error decimation */
  64793. QUADRATIC = 0
  64794. }
  64795. /**
  64796. * An implementation of the Quadratic Error simplification algorithm.
  64797. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  64798. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  64799. * @author RaananW
  64800. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64801. */
  64802. export class QuadraticErrorSimplification implements ISimplifier {
  64803. private _mesh;
  64804. private triangles;
  64805. private vertices;
  64806. private references;
  64807. private _reconstructedMesh;
  64808. /** Gets or sets the number pf sync interations */
  64809. syncIterations: number;
  64810. /** Gets or sets the aggressiveness of the simplifier */
  64811. aggressiveness: number;
  64812. /** Gets or sets the number of allowed iterations for decimation */
  64813. decimationIterations: number;
  64814. /** Gets or sets the espilon to use for bounding box computation */
  64815. boundingBoxEpsilon: number;
  64816. /**
  64817. * Creates a new QuadraticErrorSimplification
  64818. * @param _mesh defines the target mesh
  64819. */
  64820. constructor(_mesh: Mesh);
  64821. /**
  64822. * Simplification of a given mesh according to the given settings.
  64823. * Since this requires computation, it is assumed that the function runs async.
  64824. * @param settings The settings of the simplification, including quality and distance
  64825. * @param successCallback A callback that will be called after the mesh was simplified.
  64826. */
  64827. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  64828. private runDecimation;
  64829. private initWithMesh;
  64830. private init;
  64831. private reconstructMesh;
  64832. private initDecimatedMesh;
  64833. private isFlipped;
  64834. private updateTriangles;
  64835. private identifyBorder;
  64836. private updateMesh;
  64837. private vertexError;
  64838. private calculateError;
  64839. }
  64840. }
  64841. declare module BABYLON {
  64842. interface Scene {
  64843. /** @hidden (Backing field) */
  64844. _simplificationQueue: SimplificationQueue;
  64845. /**
  64846. * Gets or sets the simplification queue attached to the scene
  64847. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64848. */
  64849. simplificationQueue: SimplificationQueue;
  64850. }
  64851. interface Mesh {
  64852. /**
  64853. * Simplify the mesh according to the given array of settings.
  64854. * Function will return immediately and will simplify async
  64855. * @param settings a collection of simplification settings
  64856. * @param parallelProcessing should all levels calculate parallel or one after the other
  64857. * @param simplificationType the type of simplification to run
  64858. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64859. * @returns the current mesh
  64860. */
  64861. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64862. }
  64863. /**
  64864. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64865. * created in a scene
  64866. */
  64867. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64868. /**
  64869. * The component name helpfull to identify the component in the list of scene components.
  64870. */
  64871. readonly name: string;
  64872. /**
  64873. * The scene the component belongs to.
  64874. */
  64875. scene: Scene;
  64876. /**
  64877. * Creates a new instance of the component for the given scene
  64878. * @param scene Defines the scene to register the component in
  64879. */
  64880. constructor(scene: Scene);
  64881. /**
  64882. * Registers the component in a given scene
  64883. */
  64884. register(): void;
  64885. /**
  64886. * Rebuilds the elements related to this component in case of
  64887. * context lost for instance.
  64888. */
  64889. rebuild(): void;
  64890. /**
  64891. * Disposes the component and the associated ressources
  64892. */
  64893. dispose(): void;
  64894. private _beforeCameraUpdate;
  64895. }
  64896. }
  64897. declare module BABYLON {
  64898. /**
  64899. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64900. */
  64901. export interface INavigationEnginePlugin {
  64902. /**
  64903. * plugin name
  64904. */
  64905. name: string;
  64906. /**
  64907. * Creates a navigation mesh
  64908. * @param meshes array of all the geometry used to compute the navigatio mesh
  64909. * @param parameters bunch of parameters used to filter geometry
  64910. */
  64911. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64912. /**
  64913. * Create a navigation mesh debug mesh
  64914. * @param scene is where the mesh will be added
  64915. * @returns debug display mesh
  64916. */
  64917. createDebugNavMesh(scene: Scene): Mesh;
  64918. /**
  64919. * Get a navigation mesh constrained position, closest to the parameter position
  64920. * @param position world position
  64921. * @returns the closest point to position constrained by the navigation mesh
  64922. */
  64923. getClosestPoint(position: Vector3): Vector3;
  64924. /**
  64925. * Get a navigation mesh constrained position, closest to the parameter position
  64926. * @param position world position
  64927. * @param result output the closest point to position constrained by the navigation mesh
  64928. */
  64929. getClosestPointToRef(position: Vector3, result: Vector3): void;
  64930. /**
  64931. * Get a navigation mesh constrained position, within a particular radius
  64932. * @param position world position
  64933. * @param maxRadius the maximum distance to the constrained world position
  64934. * @returns the closest point to position constrained by the navigation mesh
  64935. */
  64936. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64937. /**
  64938. * Get a navigation mesh constrained position, within a particular radius
  64939. * @param position world position
  64940. * @param maxRadius the maximum distance to the constrained world position
  64941. * @param result output the closest point to position constrained by the navigation mesh
  64942. */
  64943. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  64944. /**
  64945. * Compute the final position from a segment made of destination-position
  64946. * @param position world position
  64947. * @param destination world position
  64948. * @returns the resulting point along the navmesh
  64949. */
  64950. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64951. /**
  64952. * Compute the final position from a segment made of destination-position
  64953. * @param position world position
  64954. * @param destination world position
  64955. * @param result output the resulting point along the navmesh
  64956. */
  64957. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  64958. /**
  64959. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64960. * @param start world position
  64961. * @param end world position
  64962. * @returns array containing world position composing the path
  64963. */
  64964. computePath(start: Vector3, end: Vector3): Vector3[];
  64965. /**
  64966. * If this plugin is supported
  64967. * @returns true if plugin is supported
  64968. */
  64969. isSupported(): boolean;
  64970. /**
  64971. * Create a new Crowd so you can add agents
  64972. * @param maxAgents the maximum agent count in the crowd
  64973. * @param maxAgentRadius the maximum radius an agent can have
  64974. * @param scene to attach the crowd to
  64975. * @returns the crowd you can add agents to
  64976. */
  64977. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64978. /**
  64979. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64980. * The queries will try to find a solution within those bounds
  64981. * default is (1,1,1)
  64982. * @param extent x,y,z value that define the extent around the queries point of reference
  64983. */
  64984. setDefaultQueryExtent(extent: Vector3): void;
  64985. /**
  64986. * Get the Bounding box extent specified by setDefaultQueryExtent
  64987. * @returns the box extent values
  64988. */
  64989. getDefaultQueryExtent(): Vector3;
  64990. /**
  64991. * build the navmesh from a previously saved state using getNavmeshData
  64992. * @param data the Uint8Array returned by getNavmeshData
  64993. */
  64994. buildFromNavmeshData(data: Uint8Array): void;
  64995. /**
  64996. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  64997. * @returns data the Uint8Array that can be saved and reused
  64998. */
  64999. getNavmeshData(): Uint8Array;
  65000. /**
  65001. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65002. * @param result output the box extent values
  65003. */
  65004. getDefaultQueryExtentToRef(result: Vector3): void;
  65005. /**
  65006. * Release all resources
  65007. */
  65008. dispose(): void;
  65009. }
  65010. /**
  65011. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65012. */
  65013. export interface ICrowd {
  65014. /**
  65015. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65016. * You can attach anything to that node. The node position is updated in the scene update tick.
  65017. * @param pos world position that will be constrained by the navigation mesh
  65018. * @param parameters agent parameters
  65019. * @param transform hooked to the agent that will be update by the scene
  65020. * @returns agent index
  65021. */
  65022. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65023. /**
  65024. * Returns the agent position in world space
  65025. * @param index agent index returned by addAgent
  65026. * @returns world space position
  65027. */
  65028. getAgentPosition(index: number): Vector3;
  65029. /**
  65030. * Gets the agent position result in world space
  65031. * @param index agent index returned by addAgent
  65032. * @param result output world space position
  65033. */
  65034. getAgentPositionToRef(index: number, result: Vector3): void;
  65035. /**
  65036. * Gets the agent velocity in world space
  65037. * @param index agent index returned by addAgent
  65038. * @returns world space velocity
  65039. */
  65040. getAgentVelocity(index: number): Vector3;
  65041. /**
  65042. * Gets the agent velocity result in world space
  65043. * @param index agent index returned by addAgent
  65044. * @param result output world space velocity
  65045. */
  65046. getAgentVelocityToRef(index: number, result: Vector3): void;
  65047. /**
  65048. * remove a particular agent previously created
  65049. * @param index agent index returned by addAgent
  65050. */
  65051. removeAgent(index: number): void;
  65052. /**
  65053. * get the list of all agents attached to this crowd
  65054. * @returns list of agent indices
  65055. */
  65056. getAgents(): number[];
  65057. /**
  65058. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65059. * @param deltaTime in seconds
  65060. */
  65061. update(deltaTime: number): void;
  65062. /**
  65063. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65064. * @param index agent index returned by addAgent
  65065. * @param destination targeted world position
  65066. */
  65067. agentGoto(index: number, destination: Vector3): void;
  65068. /**
  65069. * Teleport the agent to a new position
  65070. * @param index agent index returned by addAgent
  65071. * @param destination targeted world position
  65072. */
  65073. agentTeleport(index: number, destination: Vector3): void;
  65074. /**
  65075. * Update agent parameters
  65076. * @param index agent index returned by addAgent
  65077. * @param parameters agent parameters
  65078. */
  65079. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65080. /**
  65081. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65082. * The queries will try to find a solution within those bounds
  65083. * default is (1,1,1)
  65084. * @param extent x,y,z value that define the extent around the queries point of reference
  65085. */
  65086. setDefaultQueryExtent(extent: Vector3): void;
  65087. /**
  65088. * Get the Bounding box extent specified by setDefaultQueryExtent
  65089. * @returns the box extent values
  65090. */
  65091. getDefaultQueryExtent(): Vector3;
  65092. /**
  65093. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65094. * @param result output the box extent values
  65095. */
  65096. getDefaultQueryExtentToRef(result: Vector3): void;
  65097. /**
  65098. * Release all resources
  65099. */
  65100. dispose(): void;
  65101. }
  65102. /**
  65103. * Configures an agent
  65104. */
  65105. export interface IAgentParameters {
  65106. /**
  65107. * Agent radius. [Limit: >= 0]
  65108. */
  65109. radius: number;
  65110. /**
  65111. * Agent height. [Limit: > 0]
  65112. */
  65113. height: number;
  65114. /**
  65115. * Maximum allowed acceleration. [Limit: >= 0]
  65116. */
  65117. maxAcceleration: number;
  65118. /**
  65119. * Maximum allowed speed. [Limit: >= 0]
  65120. */
  65121. maxSpeed: number;
  65122. /**
  65123. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65124. */
  65125. collisionQueryRange: number;
  65126. /**
  65127. * The path visibility optimization range. [Limit: > 0]
  65128. */
  65129. pathOptimizationRange: number;
  65130. /**
  65131. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65132. */
  65133. separationWeight: number;
  65134. }
  65135. /**
  65136. * Configures the navigation mesh creation
  65137. */
  65138. export interface INavMeshParameters {
  65139. /**
  65140. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65141. */
  65142. cs: number;
  65143. /**
  65144. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65145. */
  65146. ch: number;
  65147. /**
  65148. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65149. */
  65150. walkableSlopeAngle: number;
  65151. /**
  65152. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65153. * be considered walkable. [Limit: >= 3] [Units: vx]
  65154. */
  65155. walkableHeight: number;
  65156. /**
  65157. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65158. */
  65159. walkableClimb: number;
  65160. /**
  65161. * The distance to erode/shrink the walkable area of the heightfield away from
  65162. * obstructions. [Limit: >=0] [Units: vx]
  65163. */
  65164. walkableRadius: number;
  65165. /**
  65166. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65167. */
  65168. maxEdgeLen: number;
  65169. /**
  65170. * The maximum distance a simplfied contour's border edges should deviate
  65171. * the original raw contour. [Limit: >=0] [Units: vx]
  65172. */
  65173. maxSimplificationError: number;
  65174. /**
  65175. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65176. */
  65177. minRegionArea: number;
  65178. /**
  65179. * Any regions with a span count smaller than this value will, if possible,
  65180. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65181. */
  65182. mergeRegionArea: number;
  65183. /**
  65184. * The maximum number of vertices allowed for polygons generated during the
  65185. * contour to polygon conversion process. [Limit: >= 3]
  65186. */
  65187. maxVertsPerPoly: number;
  65188. /**
  65189. * Sets the sampling distance to use when generating the detail mesh.
  65190. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65191. */
  65192. detailSampleDist: number;
  65193. /**
  65194. * The maximum distance the detail mesh surface should deviate from heightfield
  65195. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65196. */
  65197. detailSampleMaxError: number;
  65198. }
  65199. }
  65200. declare module BABYLON {
  65201. /**
  65202. * RecastJS navigation plugin
  65203. */
  65204. export class RecastJSPlugin implements INavigationEnginePlugin {
  65205. /**
  65206. * Reference to the Recast library
  65207. */
  65208. bjsRECAST: any;
  65209. /**
  65210. * plugin name
  65211. */
  65212. name: string;
  65213. /**
  65214. * the first navmesh created. We might extend this to support multiple navmeshes
  65215. */
  65216. navMesh: any;
  65217. /**
  65218. * Initializes the recastJS plugin
  65219. * @param recastInjection can be used to inject your own recast reference
  65220. */
  65221. constructor(recastInjection?: any);
  65222. /**
  65223. * Creates a navigation mesh
  65224. * @param meshes array of all the geometry used to compute the navigatio mesh
  65225. * @param parameters bunch of parameters used to filter geometry
  65226. */
  65227. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65228. /**
  65229. * Create a navigation mesh debug mesh
  65230. * @param scene is where the mesh will be added
  65231. * @returns debug display mesh
  65232. */
  65233. createDebugNavMesh(scene: Scene): Mesh;
  65234. /**
  65235. * Get a navigation mesh constrained position, closest to the parameter position
  65236. * @param position world position
  65237. * @returns the closest point to position constrained by the navigation mesh
  65238. */
  65239. getClosestPoint(position: Vector3): Vector3;
  65240. /**
  65241. * Get a navigation mesh constrained position, closest to the parameter position
  65242. * @param position world position
  65243. * @param result output the closest point to position constrained by the navigation mesh
  65244. */
  65245. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65246. /**
  65247. * Get a navigation mesh constrained position, within a particular radius
  65248. * @param position world position
  65249. * @param maxRadius the maximum distance to the constrained world position
  65250. * @returns the closest point to position constrained by the navigation mesh
  65251. */
  65252. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65253. /**
  65254. * Get a navigation mesh constrained position, within a particular radius
  65255. * @param position world position
  65256. * @param maxRadius the maximum distance to the constrained world position
  65257. * @param result output the closest point to position constrained by the navigation mesh
  65258. */
  65259. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65260. /**
  65261. * Compute the final position from a segment made of destination-position
  65262. * @param position world position
  65263. * @param destination world position
  65264. * @returns the resulting point along the navmesh
  65265. */
  65266. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65267. /**
  65268. * Compute the final position from a segment made of destination-position
  65269. * @param position world position
  65270. * @param destination world position
  65271. * @param result output the resulting point along the navmesh
  65272. */
  65273. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65274. /**
  65275. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65276. * @param start world position
  65277. * @param end world position
  65278. * @returns array containing world position composing the path
  65279. */
  65280. computePath(start: Vector3, end: Vector3): Vector3[];
  65281. /**
  65282. * Create a new Crowd so you can add agents
  65283. * @param maxAgents the maximum agent count in the crowd
  65284. * @param maxAgentRadius the maximum radius an agent can have
  65285. * @param scene to attach the crowd to
  65286. * @returns the crowd you can add agents to
  65287. */
  65288. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65289. /**
  65290. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65291. * The queries will try to find a solution within those bounds
  65292. * default is (1,1,1)
  65293. * @param extent x,y,z value that define the extent around the queries point of reference
  65294. */
  65295. setDefaultQueryExtent(extent: Vector3): void;
  65296. /**
  65297. * Get the Bounding box extent specified by setDefaultQueryExtent
  65298. * @returns the box extent values
  65299. */
  65300. getDefaultQueryExtent(): Vector3;
  65301. /**
  65302. * build the navmesh from a previously saved state using getNavmeshData
  65303. * @param data the Uint8Array returned by getNavmeshData
  65304. */
  65305. buildFromNavmeshData(data: Uint8Array): void;
  65306. /**
  65307. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65308. * @returns data the Uint8Array that can be saved and reused
  65309. */
  65310. getNavmeshData(): Uint8Array;
  65311. /**
  65312. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65313. * @param result output the box extent values
  65314. */
  65315. getDefaultQueryExtentToRef(result: Vector3): void;
  65316. /**
  65317. * Disposes
  65318. */
  65319. dispose(): void;
  65320. /**
  65321. * If this plugin is supported
  65322. * @returns true if plugin is supported
  65323. */
  65324. isSupported(): boolean;
  65325. }
  65326. /**
  65327. * Recast detour crowd implementation
  65328. */
  65329. export class RecastJSCrowd implements ICrowd {
  65330. /**
  65331. * Recast/detour plugin
  65332. */
  65333. bjsRECASTPlugin: RecastJSPlugin;
  65334. /**
  65335. * Link to the detour crowd
  65336. */
  65337. recastCrowd: any;
  65338. /**
  65339. * One transform per agent
  65340. */
  65341. transforms: TransformNode[];
  65342. /**
  65343. * All agents created
  65344. */
  65345. agents: number[];
  65346. /**
  65347. * Link to the scene is kept to unregister the crowd from the scene
  65348. */
  65349. private _scene;
  65350. /**
  65351. * Observer for crowd updates
  65352. */
  65353. private _onBeforeAnimationsObserver;
  65354. /**
  65355. * Constructor
  65356. * @param plugin recastJS plugin
  65357. * @param maxAgents the maximum agent count in the crowd
  65358. * @param maxAgentRadius the maximum radius an agent can have
  65359. * @param scene to attach the crowd to
  65360. * @returns the crowd you can add agents to
  65361. */
  65362. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65363. /**
  65364. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65365. * You can attach anything to that node. The node position is updated in the scene update tick.
  65366. * @param pos world position that will be constrained by the navigation mesh
  65367. * @param parameters agent parameters
  65368. * @param transform hooked to the agent that will be update by the scene
  65369. * @returns agent index
  65370. */
  65371. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65372. /**
  65373. * Returns the agent position in world space
  65374. * @param index agent index returned by addAgent
  65375. * @returns world space position
  65376. */
  65377. getAgentPosition(index: number): Vector3;
  65378. /**
  65379. * Returns the agent position result in world space
  65380. * @param index agent index returned by addAgent
  65381. * @param result output world space position
  65382. */
  65383. getAgentPositionToRef(index: number, result: Vector3): void;
  65384. /**
  65385. * Returns the agent velocity in world space
  65386. * @param index agent index returned by addAgent
  65387. * @returns world space velocity
  65388. */
  65389. getAgentVelocity(index: number): Vector3;
  65390. /**
  65391. * Returns the agent velocity result in world space
  65392. * @param index agent index returned by addAgent
  65393. * @param result output world space velocity
  65394. */
  65395. getAgentVelocityToRef(index: number, result: Vector3): void;
  65396. /**
  65397. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65398. * @param index agent index returned by addAgent
  65399. * @param destination targeted world position
  65400. */
  65401. agentGoto(index: number, destination: Vector3): void;
  65402. /**
  65403. * Teleport the agent to a new position
  65404. * @param index agent index returned by addAgent
  65405. * @param destination targeted world position
  65406. */
  65407. agentTeleport(index: number, destination: Vector3): void;
  65408. /**
  65409. * Update agent parameters
  65410. * @param index agent index returned by addAgent
  65411. * @param parameters agent parameters
  65412. */
  65413. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65414. /**
  65415. * remove a particular agent previously created
  65416. * @param index agent index returned by addAgent
  65417. */
  65418. removeAgent(index: number): void;
  65419. /**
  65420. * get the list of all agents attached to this crowd
  65421. * @returns list of agent indices
  65422. */
  65423. getAgents(): number[];
  65424. /**
  65425. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65426. * @param deltaTime in seconds
  65427. */
  65428. update(deltaTime: number): void;
  65429. /**
  65430. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65431. * The queries will try to find a solution within those bounds
  65432. * default is (1,1,1)
  65433. * @param extent x,y,z value that define the extent around the queries point of reference
  65434. */
  65435. setDefaultQueryExtent(extent: Vector3): void;
  65436. /**
  65437. * Get the Bounding box extent specified by setDefaultQueryExtent
  65438. * @returns the box extent values
  65439. */
  65440. getDefaultQueryExtent(): Vector3;
  65441. /**
  65442. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65443. * @param result output the box extent values
  65444. */
  65445. getDefaultQueryExtentToRef(result: Vector3): void;
  65446. /**
  65447. * Release all resources
  65448. */
  65449. dispose(): void;
  65450. }
  65451. }
  65452. declare module BABYLON {
  65453. /**
  65454. * Class used to enable access to IndexedDB
  65455. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65456. */
  65457. export class Database implements IOfflineProvider {
  65458. private _callbackManifestChecked;
  65459. private _currentSceneUrl;
  65460. private _db;
  65461. private _enableSceneOffline;
  65462. private _enableTexturesOffline;
  65463. private _manifestVersionFound;
  65464. private _mustUpdateRessources;
  65465. private _hasReachedQuota;
  65466. private _isSupported;
  65467. private _idbFactory;
  65468. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65469. private static IsUASupportingBlobStorage;
  65470. /**
  65471. * Gets a boolean indicating if Database storate is enabled (off by default)
  65472. */
  65473. static IDBStorageEnabled: boolean;
  65474. /**
  65475. * Gets a boolean indicating if scene must be saved in the database
  65476. */
  65477. get enableSceneOffline(): boolean;
  65478. /**
  65479. * Gets a boolean indicating if textures must be saved in the database
  65480. */
  65481. get enableTexturesOffline(): boolean;
  65482. /**
  65483. * Creates a new Database
  65484. * @param urlToScene defines the url to load the scene
  65485. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65486. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65487. */
  65488. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65489. private static _ParseURL;
  65490. private static _ReturnFullUrlLocation;
  65491. private _checkManifestFile;
  65492. /**
  65493. * Open the database and make it available
  65494. * @param successCallback defines the callback to call on success
  65495. * @param errorCallback defines the callback to call on error
  65496. */
  65497. open(successCallback: () => void, errorCallback: () => void): void;
  65498. /**
  65499. * Loads an image from the database
  65500. * @param url defines the url to load from
  65501. * @param image defines the target DOM image
  65502. */
  65503. loadImage(url: string, image: HTMLImageElement): void;
  65504. private _loadImageFromDBAsync;
  65505. private _saveImageIntoDBAsync;
  65506. private _checkVersionFromDB;
  65507. private _loadVersionFromDBAsync;
  65508. private _saveVersionIntoDBAsync;
  65509. /**
  65510. * Loads a file from database
  65511. * @param url defines the URL to load from
  65512. * @param sceneLoaded defines a callback to call on success
  65513. * @param progressCallBack defines a callback to call when progress changed
  65514. * @param errorCallback defines a callback to call on error
  65515. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65516. */
  65517. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65518. private _loadFileAsync;
  65519. private _saveFileAsync;
  65520. /**
  65521. * Validates if xhr data is correct
  65522. * @param xhr defines the request to validate
  65523. * @param dataType defines the expected data type
  65524. * @returns true if data is correct
  65525. */
  65526. private static _ValidateXHRData;
  65527. }
  65528. }
  65529. declare module BABYLON {
  65530. /** @hidden */
  65531. export var gpuUpdateParticlesPixelShader: {
  65532. name: string;
  65533. shader: string;
  65534. };
  65535. }
  65536. declare module BABYLON {
  65537. /** @hidden */
  65538. export var gpuUpdateParticlesVertexShader: {
  65539. name: string;
  65540. shader: string;
  65541. };
  65542. }
  65543. declare module BABYLON {
  65544. /** @hidden */
  65545. export var clipPlaneFragmentDeclaration2: {
  65546. name: string;
  65547. shader: string;
  65548. };
  65549. }
  65550. declare module BABYLON {
  65551. /** @hidden */
  65552. export var gpuRenderParticlesPixelShader: {
  65553. name: string;
  65554. shader: string;
  65555. };
  65556. }
  65557. declare module BABYLON {
  65558. /** @hidden */
  65559. export var clipPlaneVertexDeclaration2: {
  65560. name: string;
  65561. shader: string;
  65562. };
  65563. }
  65564. declare module BABYLON {
  65565. /** @hidden */
  65566. export var gpuRenderParticlesVertexShader: {
  65567. name: string;
  65568. shader: string;
  65569. };
  65570. }
  65571. declare module BABYLON {
  65572. /**
  65573. * This represents a GPU particle system in Babylon
  65574. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65575. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65576. */
  65577. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65578. /**
  65579. * The layer mask we are rendering the particles through.
  65580. */
  65581. layerMask: number;
  65582. private _capacity;
  65583. private _activeCount;
  65584. private _currentActiveCount;
  65585. private _accumulatedCount;
  65586. private _renderEffect;
  65587. private _updateEffect;
  65588. private _buffer0;
  65589. private _buffer1;
  65590. private _spriteBuffer;
  65591. private _updateVAO;
  65592. private _renderVAO;
  65593. private _targetIndex;
  65594. private _sourceBuffer;
  65595. private _targetBuffer;
  65596. private _engine;
  65597. private _currentRenderId;
  65598. private _started;
  65599. private _stopped;
  65600. private _timeDelta;
  65601. private _randomTexture;
  65602. private _randomTexture2;
  65603. private _attributesStrideSize;
  65604. private _updateEffectOptions;
  65605. private _randomTextureSize;
  65606. private _actualFrame;
  65607. private _customEffect;
  65608. private readonly _rawTextureWidth;
  65609. /**
  65610. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65611. */
  65612. static get IsSupported(): boolean;
  65613. /**
  65614. * An event triggered when the system is disposed.
  65615. */
  65616. onDisposeObservable: Observable<IParticleSystem>;
  65617. /**
  65618. * Gets the maximum number of particles active at the same time.
  65619. * @returns The max number of active particles.
  65620. */
  65621. getCapacity(): number;
  65622. /**
  65623. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65624. * to override the particles.
  65625. */
  65626. forceDepthWrite: boolean;
  65627. /**
  65628. * Gets or set the number of active particles
  65629. */
  65630. get activeParticleCount(): number;
  65631. set activeParticleCount(value: number);
  65632. private _preWarmDone;
  65633. /**
  65634. * Specifies if the particles are updated in emitter local space or world space.
  65635. */
  65636. isLocal: boolean;
  65637. /**
  65638. * Is this system ready to be used/rendered
  65639. * @return true if the system is ready
  65640. */
  65641. isReady(): boolean;
  65642. /**
  65643. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65644. * @returns True if it has been started, otherwise false.
  65645. */
  65646. isStarted(): boolean;
  65647. /**
  65648. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  65649. * @returns True if it has been stopped, otherwise false.
  65650. */
  65651. isStopped(): boolean;
  65652. /**
  65653. * Gets a boolean indicating that the system is stopping
  65654. * @returns true if the system is currently stopping
  65655. */
  65656. isStopping(): boolean;
  65657. /**
  65658. * Gets the number of particles active at the same time.
  65659. * @returns The number of active particles.
  65660. */
  65661. getActiveCount(): number;
  65662. /**
  65663. * Starts the particle system and begins to emit
  65664. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65665. */
  65666. start(delay?: number): void;
  65667. /**
  65668. * Stops the particle system.
  65669. */
  65670. stop(): void;
  65671. /**
  65672. * Remove all active particles
  65673. */
  65674. reset(): void;
  65675. /**
  65676. * Returns the string "GPUParticleSystem"
  65677. * @returns a string containing the class name
  65678. */
  65679. getClassName(): string;
  65680. /**
  65681. * Gets the custom effect used to render the particles
  65682. * @param blendMode Blend mode for which the effect should be retrieved
  65683. * @returns The effect
  65684. */
  65685. getCustomEffect(blendMode?: number): Nullable<Effect>;
  65686. /**
  65687. * Sets the custom effect used to render the particles
  65688. * @param effect The effect to set
  65689. * @param blendMode Blend mode for which the effect should be set
  65690. */
  65691. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  65692. /** @hidden */
  65693. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  65694. /**
  65695. * Observable that will be called just before the particles are drawn
  65696. */
  65697. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  65698. /**
  65699. * Gets the name of the particle vertex shader
  65700. */
  65701. get vertexShaderName(): string;
  65702. private _colorGradientsTexture;
  65703. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65704. /**
  65705. * Adds a new color gradient
  65706. * @param gradient defines the gradient to use (between 0 and 1)
  65707. * @param color1 defines the color to affect to the specified gradient
  65708. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65709. * @returns the current particle system
  65710. */
  65711. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65712. private _refreshColorGradient;
  65713. /** Force the system to rebuild all gradients that need to be resync */
  65714. forceRefreshGradients(): void;
  65715. /**
  65716. * Remove a specific color gradient
  65717. * @param gradient defines the gradient to remove
  65718. * @returns the current particle system
  65719. */
  65720. removeColorGradient(gradient: number): GPUParticleSystem;
  65721. private _angularSpeedGradientsTexture;
  65722. private _sizeGradientsTexture;
  65723. private _velocityGradientsTexture;
  65724. private _limitVelocityGradientsTexture;
  65725. private _dragGradientsTexture;
  65726. private _addFactorGradient;
  65727. /**
  65728. * Adds a new size gradient
  65729. * @param gradient defines the gradient to use (between 0 and 1)
  65730. * @param factor defines the size factor to affect to the specified gradient
  65731. * @returns the current particle system
  65732. */
  65733. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65734. /**
  65735. * Remove a specific size gradient
  65736. * @param gradient defines the gradient to remove
  65737. * @returns the current particle system
  65738. */
  65739. removeSizeGradient(gradient: number): GPUParticleSystem;
  65740. private _refreshFactorGradient;
  65741. /**
  65742. * Adds a new angular speed gradient
  65743. * @param gradient defines the gradient to use (between 0 and 1)
  65744. * @param factor defines the angular speed to affect to the specified gradient
  65745. * @returns the current particle system
  65746. */
  65747. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65748. /**
  65749. * Remove a specific angular speed gradient
  65750. * @param gradient defines the gradient to remove
  65751. * @returns the current particle system
  65752. */
  65753. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65754. /**
  65755. * Adds a new velocity gradient
  65756. * @param gradient defines the gradient to use (between 0 and 1)
  65757. * @param factor defines the velocity to affect to the specified gradient
  65758. * @returns the current particle system
  65759. */
  65760. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65761. /**
  65762. * Remove a specific velocity gradient
  65763. * @param gradient defines the gradient to remove
  65764. * @returns the current particle system
  65765. */
  65766. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65767. /**
  65768. * Adds a new limit velocity gradient
  65769. * @param gradient defines the gradient to use (between 0 and 1)
  65770. * @param factor defines the limit velocity value to affect to the specified gradient
  65771. * @returns the current particle system
  65772. */
  65773. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65774. /**
  65775. * Remove a specific limit velocity gradient
  65776. * @param gradient defines the gradient to remove
  65777. * @returns the current particle system
  65778. */
  65779. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65780. /**
  65781. * Adds a new drag gradient
  65782. * @param gradient defines the gradient to use (between 0 and 1)
  65783. * @param factor defines the drag value to affect to the specified gradient
  65784. * @returns the current particle system
  65785. */
  65786. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65787. /**
  65788. * Remove a specific drag gradient
  65789. * @param gradient defines the gradient to remove
  65790. * @returns the current particle system
  65791. */
  65792. removeDragGradient(gradient: number): GPUParticleSystem;
  65793. /**
  65794. * Not supported by GPUParticleSystem
  65795. * @param gradient defines the gradient to use (between 0 and 1)
  65796. * @param factor defines the emit rate value to affect to the specified gradient
  65797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65798. * @returns the current particle system
  65799. */
  65800. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65801. /**
  65802. * Not supported by GPUParticleSystem
  65803. * @param gradient defines the gradient to remove
  65804. * @returns the current particle system
  65805. */
  65806. removeEmitRateGradient(gradient: number): IParticleSystem;
  65807. /**
  65808. * Not supported by GPUParticleSystem
  65809. * @param gradient defines the gradient to use (between 0 and 1)
  65810. * @param factor defines the start size value to affect to the specified gradient
  65811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65812. * @returns the current particle system
  65813. */
  65814. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65815. /**
  65816. * Not supported by GPUParticleSystem
  65817. * @param gradient defines the gradient to remove
  65818. * @returns the current particle system
  65819. */
  65820. removeStartSizeGradient(gradient: number): IParticleSystem;
  65821. /**
  65822. * Not supported by GPUParticleSystem
  65823. * @param gradient defines the gradient to use (between 0 and 1)
  65824. * @param min defines the color remap minimal range
  65825. * @param max defines the color remap maximal range
  65826. * @returns the current particle system
  65827. */
  65828. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65829. /**
  65830. * Not supported by GPUParticleSystem
  65831. * @param gradient defines the gradient to remove
  65832. * @returns the current particle system
  65833. */
  65834. removeColorRemapGradient(): IParticleSystem;
  65835. /**
  65836. * Not supported by GPUParticleSystem
  65837. * @param gradient defines the gradient to use (between 0 and 1)
  65838. * @param min defines the alpha remap minimal range
  65839. * @param max defines the alpha remap maximal range
  65840. * @returns the current particle system
  65841. */
  65842. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65843. /**
  65844. * Not supported by GPUParticleSystem
  65845. * @param gradient defines the gradient to remove
  65846. * @returns the current particle system
  65847. */
  65848. removeAlphaRemapGradient(): IParticleSystem;
  65849. /**
  65850. * Not supported by GPUParticleSystem
  65851. * @param gradient defines the gradient to use (between 0 and 1)
  65852. * @param color defines the color to affect to the specified gradient
  65853. * @returns the current particle system
  65854. */
  65855. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65856. /**
  65857. * Not supported by GPUParticleSystem
  65858. * @param gradient defines the gradient to remove
  65859. * @returns the current particle system
  65860. */
  65861. removeRampGradient(): IParticleSystem;
  65862. /**
  65863. * Not supported by GPUParticleSystem
  65864. * @returns the list of ramp gradients
  65865. */
  65866. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65867. /**
  65868. * Not supported by GPUParticleSystem
  65869. * Gets or sets a boolean indicating that ramp gradients must be used
  65870. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65871. */
  65872. get useRampGradients(): boolean;
  65873. set useRampGradients(value: boolean);
  65874. /**
  65875. * Not supported by GPUParticleSystem
  65876. * @param gradient defines the gradient to use (between 0 and 1)
  65877. * @param factor defines the life time factor to affect to the specified gradient
  65878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65879. * @returns the current particle system
  65880. */
  65881. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65882. /**
  65883. * Not supported by GPUParticleSystem
  65884. * @param gradient defines the gradient to remove
  65885. * @returns the current particle system
  65886. */
  65887. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65888. /**
  65889. * Instantiates a GPU particle system.
  65890. * 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.
  65891. * @param name The name of the particle system
  65892. * @param options The options used to create the system
  65893. * @param scene The scene the particle system belongs to
  65894. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65895. * @param customEffect a custom effect used to change the way particles are rendered by default
  65896. */
  65897. constructor(name: string, options: Partial<{
  65898. capacity: number;
  65899. randomTextureSize: number;
  65900. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  65901. protected _reset(): void;
  65902. private _createUpdateVAO;
  65903. private _createRenderVAO;
  65904. private _initialize;
  65905. /** @hidden */
  65906. _recreateUpdateEffect(): void;
  65907. private _getEffect;
  65908. /**
  65909. * Fill the defines array according to the current settings of the particle system
  65910. * @param defines Array to be updated
  65911. * @param blendMode blend mode to take into account when updating the array
  65912. */
  65913. fillDefines(defines: Array<string>, blendMode?: number): void;
  65914. /**
  65915. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  65916. * @param uniforms Uniforms array to fill
  65917. * @param attributes Attributes array to fill
  65918. * @param samplers Samplers array to fill
  65919. */
  65920. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  65921. /** @hidden */
  65922. _recreateRenderEffect(): Effect;
  65923. /**
  65924. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65925. * @param preWarm defines if we are in the pre-warmimg phase
  65926. */
  65927. animate(preWarm?: boolean): void;
  65928. private _createFactorGradientTexture;
  65929. private _createSizeGradientTexture;
  65930. private _createAngularSpeedGradientTexture;
  65931. private _createVelocityGradientTexture;
  65932. private _createLimitVelocityGradientTexture;
  65933. private _createDragGradientTexture;
  65934. private _createColorGradientTexture;
  65935. /**
  65936. * Renders the particle system in its current state
  65937. * @param preWarm defines if the system should only update the particles but not render them
  65938. * @returns the current number of particles
  65939. */
  65940. render(preWarm?: boolean): number;
  65941. /**
  65942. * Rebuilds the particle system
  65943. */
  65944. rebuild(): void;
  65945. private _releaseBuffers;
  65946. private _releaseVAOs;
  65947. /**
  65948. * Disposes the particle system and free the associated resources
  65949. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65950. */
  65951. dispose(disposeTexture?: boolean): void;
  65952. /**
  65953. * Clones the particle system.
  65954. * @param name The name of the cloned object
  65955. * @param newEmitter The new emitter to use
  65956. * @returns the cloned particle system
  65957. */
  65958. clone(name: string, newEmitter: any): GPUParticleSystem;
  65959. /**
  65960. * Serializes the particle system to a JSON object
  65961. * @param serializeTexture defines if the texture must be serialized as well
  65962. * @returns the JSON object
  65963. */
  65964. serialize(serializeTexture?: boolean): any;
  65965. /**
  65966. * Parses a JSON object to create a GPU particle system.
  65967. * @param parsedParticleSystem The JSON object to parse
  65968. * @param scene The scene to create the particle system in
  65969. * @param rootUrl The root url to use to load external dependencies like texture
  65970. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65971. * @returns the parsed GPU particle system
  65972. */
  65973. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65974. }
  65975. }
  65976. declare module BABYLON {
  65977. /**
  65978. * Represents a set of particle systems working together to create a specific effect
  65979. */
  65980. export class ParticleSystemSet implements IDisposable {
  65981. /**
  65982. * Gets or sets base Assets URL
  65983. */
  65984. static BaseAssetsUrl: string;
  65985. private _emitterCreationOptions;
  65986. private _emitterNode;
  65987. /**
  65988. * Gets the particle system list
  65989. */
  65990. systems: IParticleSystem[];
  65991. /**
  65992. * Gets the emitter node used with this set
  65993. */
  65994. get emitterNode(): Nullable<TransformNode>;
  65995. /**
  65996. * Creates a new emitter mesh as a sphere
  65997. * @param options defines the options used to create the sphere
  65998. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65999. * @param scene defines the hosting scene
  66000. */
  66001. setEmitterAsSphere(options: {
  66002. diameter: number;
  66003. segments: number;
  66004. color: Color3;
  66005. }, renderingGroupId: number, scene: Scene): void;
  66006. /**
  66007. * Starts all particle systems of the set
  66008. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66009. */
  66010. start(emitter?: AbstractMesh): void;
  66011. /**
  66012. * Release all associated resources
  66013. */
  66014. dispose(): void;
  66015. /**
  66016. * Serialize the set into a JSON compatible object
  66017. * @param serializeTexture defines if the texture must be serialized as well
  66018. * @returns a JSON compatible representation of the set
  66019. */
  66020. serialize(serializeTexture?: boolean): any;
  66021. /**
  66022. * Parse a new ParticleSystemSet from a serialized source
  66023. * @param data defines a JSON compatible representation of the set
  66024. * @param scene defines the hosting scene
  66025. * @param gpu defines if we want GPU particles or CPU particles
  66026. * @returns a new ParticleSystemSet
  66027. */
  66028. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66029. }
  66030. }
  66031. declare module BABYLON {
  66032. /**
  66033. * This class is made for on one-liner static method to help creating particle system set.
  66034. */
  66035. export class ParticleHelper {
  66036. /**
  66037. * Gets or sets base Assets URL
  66038. */
  66039. static BaseAssetsUrl: string;
  66040. /** Define the Url to load snippets */
  66041. static SnippetUrl: string;
  66042. /**
  66043. * Create a default particle system that you can tweak
  66044. * @param emitter defines the emitter to use
  66045. * @param capacity defines the system capacity (default is 500 particles)
  66046. * @param scene defines the hosting scene
  66047. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66048. * @returns the new Particle system
  66049. */
  66050. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66051. /**
  66052. * This is the main static method (one-liner) of this helper to create different particle systems
  66053. * @param type This string represents the type to the particle system to create
  66054. * @param scene The scene where the particle system should live
  66055. * @param gpu If the system will use gpu
  66056. * @returns the ParticleSystemSet created
  66057. */
  66058. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66059. /**
  66060. * Static function used to export a particle system to a ParticleSystemSet variable.
  66061. * Please note that the emitter shape is not exported
  66062. * @param systems defines the particle systems to export
  66063. * @returns the created particle system set
  66064. */
  66065. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66066. /**
  66067. * Creates a particle system from a snippet saved in a remote file
  66068. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66069. * @param url defines the url to load from
  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 ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66076. /**
  66077. * Creates a particle system from a snippet saved by the particle system editor
  66078. * @param snippetId defines the snippet to load
  66079. * @param scene defines the hosting scene
  66080. * @param gpu If the system will use gpu
  66081. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66082. * @returns a promise that will resolve to the new particle system
  66083. */
  66084. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66085. }
  66086. }
  66087. declare module BABYLON {
  66088. interface Engine {
  66089. /**
  66090. * Create an effect to use with particle systems.
  66091. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66092. * the particle system for which you want to create a custom effect in the last parameter
  66093. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66094. * @param uniformsNames defines a list of attribute names
  66095. * @param samplers defines an array of string used to represent textures
  66096. * @param defines defines the string containing the defines to use to compile the shaders
  66097. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66098. * @param onCompiled defines a function to call when the effect creation is successful
  66099. * @param onError defines a function to call when the effect creation has failed
  66100. * @param particleSystem the particle system you want to create the effect for
  66101. * @returns the new Effect
  66102. */
  66103. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66104. }
  66105. interface Mesh {
  66106. /**
  66107. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66108. * @returns an array of IParticleSystem
  66109. */
  66110. getEmittedParticleSystems(): IParticleSystem[];
  66111. /**
  66112. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66113. * @returns an array of IParticleSystem
  66114. */
  66115. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66116. }
  66117. /**
  66118. * @hidden
  66119. */
  66120. export var _IDoNeedToBeInTheBuild: number;
  66121. }
  66122. declare module BABYLON {
  66123. /** Defines the 4 color options */
  66124. export enum PointColor {
  66125. /** color value */
  66126. Color = 2,
  66127. /** uv value */
  66128. UV = 1,
  66129. /** random value */
  66130. Random = 0,
  66131. /** stated value */
  66132. Stated = 3
  66133. }
  66134. /**
  66135. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66136. * 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.
  66137. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66138. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66139. *
  66140. * Full documentation here : TO BE ENTERED
  66141. */
  66142. export class PointsCloudSystem implements IDisposable {
  66143. /**
  66144. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66145. * Example : var p = SPS.particles[i];
  66146. */
  66147. particles: CloudPoint[];
  66148. /**
  66149. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66150. */
  66151. nbParticles: number;
  66152. /**
  66153. * This a counter for your own usage. It's not set by any SPS functions.
  66154. */
  66155. counter: number;
  66156. /**
  66157. * The PCS name. This name is also given to the underlying mesh.
  66158. */
  66159. name: string;
  66160. /**
  66161. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66162. */
  66163. mesh: Mesh;
  66164. /**
  66165. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66166. * Please read :
  66167. */
  66168. vars: any;
  66169. /**
  66170. * @hidden
  66171. */
  66172. _size: number;
  66173. private _scene;
  66174. private _promises;
  66175. private _positions;
  66176. private _indices;
  66177. private _normals;
  66178. private _colors;
  66179. private _uvs;
  66180. private _indices32;
  66181. private _positions32;
  66182. private _colors32;
  66183. private _uvs32;
  66184. private _updatable;
  66185. private _isVisibilityBoxLocked;
  66186. private _alwaysVisible;
  66187. private _groups;
  66188. private _groupCounter;
  66189. private _computeParticleColor;
  66190. private _computeParticleTexture;
  66191. private _computeParticleRotation;
  66192. private _computeBoundingBox;
  66193. private _isReady;
  66194. /**
  66195. * Creates a PCS (Points Cloud System) object
  66196. * @param name (String) is the PCS name, this will be the underlying mesh name
  66197. * @param pointSize (number) is the size for each point
  66198. * @param scene (Scene) is the scene in which the PCS is added
  66199. * @param options defines the options of the PCS e.g.
  66200. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66201. */
  66202. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66203. updatable?: boolean;
  66204. });
  66205. /**
  66206. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66207. * If no points were added to the PCS, the returned mesh is just a single point.
  66208. * @returns a promise for the created mesh
  66209. */
  66210. buildMeshAsync(): Promise<Mesh>;
  66211. /**
  66212. * @hidden
  66213. */
  66214. private _buildMesh;
  66215. private _addParticle;
  66216. private _randomUnitVector;
  66217. private _getColorIndicesForCoord;
  66218. private _setPointsColorOrUV;
  66219. private _colorFromTexture;
  66220. private _calculateDensity;
  66221. /**
  66222. * Adds points to the PCS in random positions within a unit sphere
  66223. * @param nb (positive integer) the number of particles to be created from this model
  66224. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66225. * @returns the number of groups in the system
  66226. */
  66227. addPoints(nb: number, pointFunction?: any): number;
  66228. /**
  66229. * Adds points to the PCS from the surface of the model shape
  66230. * @param mesh is any Mesh object that will be used as a surface model for the points
  66231. * @param nb (positive integer) the number of particles to be created from this model
  66232. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66233. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66234. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66235. * @returns the number of groups in the system
  66236. */
  66237. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66238. /**
  66239. * Adds points to the PCS inside the model shape
  66240. * @param mesh is any Mesh object that will be used as a surface model for the points
  66241. * @param nb (positive integer) the number of particles to be created from this model
  66242. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66243. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66244. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66245. * @returns the number of groups in the system
  66246. */
  66247. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66248. /**
  66249. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66250. * This method calls `updateParticle()` for each particle of the SPS.
  66251. * For an animated SPS, it is usually called within the render loop.
  66252. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66253. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66254. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66255. * @returns the PCS.
  66256. */
  66257. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66258. /**
  66259. * Disposes the PCS.
  66260. */
  66261. dispose(): void;
  66262. /**
  66263. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66264. * doc :
  66265. * @returns the PCS.
  66266. */
  66267. refreshVisibleSize(): PointsCloudSystem;
  66268. /**
  66269. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66270. * @param size the size (float) of the visibility box
  66271. * note : this doesn't lock the PCS mesh bounding box.
  66272. * doc :
  66273. */
  66274. setVisibilityBox(size: number): void;
  66275. /**
  66276. * Gets whether the PCS is always visible or not
  66277. * doc :
  66278. */
  66279. get isAlwaysVisible(): boolean;
  66280. /**
  66281. * Sets the PCS as always visible or not
  66282. * doc :
  66283. */
  66284. set isAlwaysVisible(val: boolean);
  66285. /**
  66286. * Tells to `setParticles()` to compute the particle rotations or not
  66287. * Default value : false. The PCS is faster when it's set to false
  66288. * Note : particle rotations are only applied to parent particles
  66289. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66290. */
  66291. set computeParticleRotation(val: boolean);
  66292. /**
  66293. * Tells to `setParticles()` to compute the particle colors or not.
  66294. * Default value : true. The PCS is faster when it's set to false.
  66295. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66296. */
  66297. set computeParticleColor(val: boolean);
  66298. set computeParticleTexture(val: boolean);
  66299. /**
  66300. * Gets if `setParticles()` computes the particle colors or not.
  66301. * Default value : false. The PCS is faster when it's set to false.
  66302. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66303. */
  66304. get computeParticleColor(): boolean;
  66305. /**
  66306. * Gets if `setParticles()` computes the particle textures or not.
  66307. * Default value : false. The PCS is faster when it's set to false.
  66308. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66309. */
  66310. get computeParticleTexture(): boolean;
  66311. /**
  66312. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66313. */
  66314. set computeBoundingBox(val: boolean);
  66315. /**
  66316. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66317. */
  66318. get computeBoundingBox(): boolean;
  66319. /**
  66320. * This function does nothing. It may be overwritten to set all the particle first values.
  66321. * The PCS doesn't call this function, you may have to call it by your own.
  66322. * doc :
  66323. */
  66324. initParticles(): void;
  66325. /**
  66326. * This function does nothing. It may be overwritten to recycle a particle
  66327. * The PCS doesn't call this function, you can to call it
  66328. * doc :
  66329. * @param particle The particle to recycle
  66330. * @returns the recycled particle
  66331. */
  66332. recycleParticle(particle: CloudPoint): CloudPoint;
  66333. /**
  66334. * Updates a particle : this function should be overwritten by the user.
  66335. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66336. * doc :
  66337. * @example : just set a particle position or velocity and recycle conditions
  66338. * @param particle The particle to update
  66339. * @returns the updated particle
  66340. */
  66341. updateParticle(particle: CloudPoint): CloudPoint;
  66342. /**
  66343. * This will be called before any other treatment by `setParticles()` and 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. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66350. /**
  66351. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66352. * This will be passed three parameters.
  66353. * This does nothing and may be overwritten by the user.
  66354. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66355. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66356. * @param update the boolean update value actually passed to setParticles()
  66357. */
  66358. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66359. }
  66360. }
  66361. declare module BABYLON {
  66362. /**
  66363. * Represents one particle of a points cloud system.
  66364. */
  66365. export class CloudPoint {
  66366. /**
  66367. * particle global index
  66368. */
  66369. idx: number;
  66370. /**
  66371. * The color of the particle
  66372. */
  66373. color: Nullable<Color4>;
  66374. /**
  66375. * The world space position of the particle.
  66376. */
  66377. position: Vector3;
  66378. /**
  66379. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66380. */
  66381. rotation: Vector3;
  66382. /**
  66383. * The world space rotation quaternion of the particle.
  66384. */
  66385. rotationQuaternion: Nullable<Quaternion>;
  66386. /**
  66387. * The uv of the particle.
  66388. */
  66389. uv: Nullable<Vector2>;
  66390. /**
  66391. * The current speed of the particle.
  66392. */
  66393. velocity: Vector3;
  66394. /**
  66395. * The pivot point in the particle local space.
  66396. */
  66397. pivot: Vector3;
  66398. /**
  66399. * Must the particle be translated from its pivot point in its local space ?
  66400. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66401. * Default : false
  66402. */
  66403. translateFromPivot: boolean;
  66404. /**
  66405. * Index of this particle in the global "positions" array (Internal use)
  66406. * @hidden
  66407. */
  66408. _pos: number;
  66409. /**
  66410. * @hidden Index of this particle in the global "indices" array (Internal use)
  66411. */
  66412. _ind: number;
  66413. /**
  66414. * Group this particle belongs to
  66415. */
  66416. _group: PointsGroup;
  66417. /**
  66418. * Group id of this particle
  66419. */
  66420. groupId: number;
  66421. /**
  66422. * Index of the particle in its group id (Internal use)
  66423. */
  66424. idxInGroup: number;
  66425. /**
  66426. * @hidden Particle BoundingInfo object (Internal use)
  66427. */
  66428. _boundingInfo: BoundingInfo;
  66429. /**
  66430. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66431. */
  66432. _pcs: PointsCloudSystem;
  66433. /**
  66434. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66435. */
  66436. _stillInvisible: boolean;
  66437. /**
  66438. * @hidden Last computed particle rotation matrix
  66439. */
  66440. _rotationMatrix: number[];
  66441. /**
  66442. * Parent particle Id, if any.
  66443. * Default null.
  66444. */
  66445. parentId: Nullable<number>;
  66446. /**
  66447. * @hidden Internal global position in the PCS.
  66448. */
  66449. _globalPosition: Vector3;
  66450. /**
  66451. * Creates a Point Cloud object.
  66452. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66453. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66454. * @param group (PointsGroup) is the group the particle belongs to
  66455. * @param groupId (integer) is the group identifier in the PCS.
  66456. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66457. * @param pcs defines the PCS it is associated to
  66458. */
  66459. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66460. /**
  66461. * get point size
  66462. */
  66463. get size(): Vector3;
  66464. /**
  66465. * Set point size
  66466. */
  66467. set size(scale: Vector3);
  66468. /**
  66469. * Legacy support, changed quaternion to rotationQuaternion
  66470. */
  66471. get quaternion(): Nullable<Quaternion>;
  66472. /**
  66473. * Legacy support, changed quaternion to rotationQuaternion
  66474. */
  66475. set quaternion(q: Nullable<Quaternion>);
  66476. /**
  66477. * Returns a boolean. True if the particle intersects a mesh, else false
  66478. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66479. * @param target is the object (point or mesh) what the intersection is computed against
  66480. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66481. * @returns true if it intersects
  66482. */
  66483. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66484. /**
  66485. * get the rotation matrix of the particle
  66486. * @hidden
  66487. */
  66488. getRotationMatrix(m: Matrix): void;
  66489. }
  66490. /**
  66491. * Represents a group of points in a points cloud system
  66492. * * PCS internal tool, don't use it manually.
  66493. */
  66494. export class PointsGroup {
  66495. /**
  66496. * The group id
  66497. * @hidden
  66498. */
  66499. groupID: number;
  66500. /**
  66501. * image data for group (internal use)
  66502. * @hidden
  66503. */
  66504. _groupImageData: Nullable<ArrayBufferView>;
  66505. /**
  66506. * Image Width (internal use)
  66507. * @hidden
  66508. */
  66509. _groupImgWidth: number;
  66510. /**
  66511. * Image Height (internal use)
  66512. * @hidden
  66513. */
  66514. _groupImgHeight: number;
  66515. /**
  66516. * Custom position function (internal use)
  66517. * @hidden
  66518. */
  66519. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66520. /**
  66521. * density per facet for surface points
  66522. * @hidden
  66523. */
  66524. _groupDensity: number[];
  66525. /**
  66526. * Only when points are colored by texture carries pointer to texture list array
  66527. * @hidden
  66528. */
  66529. _textureNb: number;
  66530. /**
  66531. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66532. * PCS internal tool, don't use it manually.
  66533. * @hidden
  66534. */
  66535. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66536. }
  66537. }
  66538. declare module BABYLON {
  66539. interface Scene {
  66540. /** @hidden (Backing field) */
  66541. _physicsEngine: Nullable<IPhysicsEngine>;
  66542. /** @hidden */
  66543. _physicsTimeAccumulator: number;
  66544. /**
  66545. * Gets the current physics engine
  66546. * @returns a IPhysicsEngine or null if none attached
  66547. */
  66548. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66549. /**
  66550. * Enables physics to the current scene
  66551. * @param gravity defines the scene's gravity for the physics engine
  66552. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66553. * @return a boolean indicating if the physics engine was initialized
  66554. */
  66555. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66556. /**
  66557. * Disables and disposes the physics engine associated with the scene
  66558. */
  66559. disablePhysicsEngine(): void;
  66560. /**
  66561. * Gets a boolean indicating if there is an active physics engine
  66562. * @returns a boolean indicating if there is an active physics engine
  66563. */
  66564. isPhysicsEnabled(): boolean;
  66565. /**
  66566. * Deletes a physics compound impostor
  66567. * @param compound defines the compound to delete
  66568. */
  66569. deleteCompoundImpostor(compound: any): void;
  66570. /**
  66571. * An event triggered when physic simulation is about to be run
  66572. */
  66573. onBeforePhysicsObservable: Observable<Scene>;
  66574. /**
  66575. * An event triggered when physic simulation has been done
  66576. */
  66577. onAfterPhysicsObservable: Observable<Scene>;
  66578. }
  66579. interface AbstractMesh {
  66580. /** @hidden */
  66581. _physicsImpostor: Nullable<PhysicsImpostor>;
  66582. /**
  66583. * Gets or sets impostor used for physic simulation
  66584. * @see http://doc.babylonjs.com/features/physics_engine
  66585. */
  66586. physicsImpostor: Nullable<PhysicsImpostor>;
  66587. /**
  66588. * Gets the current physics impostor
  66589. * @see http://doc.babylonjs.com/features/physics_engine
  66590. * @returns a physics impostor or null
  66591. */
  66592. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66593. /** Apply a physic impulse to the mesh
  66594. * @param force defines the force to apply
  66595. * @param contactPoint defines where to apply the force
  66596. * @returns the current mesh
  66597. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66598. */
  66599. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66600. /**
  66601. * Creates a physic joint between two meshes
  66602. * @param otherMesh defines the other mesh to use
  66603. * @param pivot1 defines the pivot to use on this mesh
  66604. * @param pivot2 defines the pivot to use on the other mesh
  66605. * @param options defines additional options (can be plugin dependent)
  66606. * @returns the current mesh
  66607. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66608. */
  66609. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66610. /** @hidden */
  66611. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66612. }
  66613. /**
  66614. * Defines the physics engine scene component responsible to manage a physics engine
  66615. */
  66616. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66617. /**
  66618. * The component name helpful to identify the component in the list of scene components.
  66619. */
  66620. readonly name: string;
  66621. /**
  66622. * The scene the component belongs to.
  66623. */
  66624. scene: Scene;
  66625. /**
  66626. * Creates a new instance of the component for the given scene
  66627. * @param scene Defines the scene to register the component in
  66628. */
  66629. constructor(scene: Scene);
  66630. /**
  66631. * Registers the component in a given scene
  66632. */
  66633. register(): void;
  66634. /**
  66635. * Rebuilds the elements related to this component in case of
  66636. * context lost for instance.
  66637. */
  66638. rebuild(): void;
  66639. /**
  66640. * Disposes the component and the associated ressources
  66641. */
  66642. dispose(): void;
  66643. }
  66644. }
  66645. declare module BABYLON {
  66646. /**
  66647. * A helper for physics simulations
  66648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66649. */
  66650. export class PhysicsHelper {
  66651. private _scene;
  66652. private _physicsEngine;
  66653. /**
  66654. * Initializes the Physics helper
  66655. * @param scene Babylon.js scene
  66656. */
  66657. constructor(scene: Scene);
  66658. /**
  66659. * Applies a radial explosion impulse
  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. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66667. /**
  66668. * Applies a radial explosion force
  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 radial explosion event, or null
  66674. */
  66675. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66676. /**
  66677. * Creates a gravitational field
  66678. * @param origin the origin of the explosion
  66679. * @param radiusOrEventOptions the radius or the options of radial explosion
  66680. * @param strength the explosion strength
  66681. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66682. * @returns A physics gravitational field event, or null
  66683. */
  66684. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66685. /**
  66686. * Creates a physics updraft event
  66687. * @param origin the origin of the updraft
  66688. * @param radiusOrEventOptions the radius or the options of the updraft
  66689. * @param strength the strength of the updraft
  66690. * @param height the height of the updraft
  66691. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66692. * @returns A physics updraft event, or null
  66693. */
  66694. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66695. /**
  66696. * Creates a physics vortex event
  66697. * @param origin the of the vortex
  66698. * @param radiusOrEventOptions the radius or the options of the vortex
  66699. * @param strength the strength of the vortex
  66700. * @param height the height of the vortex
  66701. * @returns a Physics vortex event, or null
  66702. * A physics vortex event or null
  66703. */
  66704. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66705. }
  66706. /**
  66707. * Represents a physics radial explosion event
  66708. */
  66709. class PhysicsRadialExplosionEvent {
  66710. private _scene;
  66711. private _options;
  66712. private _sphere;
  66713. private _dataFetched;
  66714. /**
  66715. * Initializes a radial explosioin event
  66716. * @param _scene BabylonJS scene
  66717. * @param _options The options for the vortex event
  66718. */
  66719. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66720. /**
  66721. * Returns the data related to the radial explosion event (sphere).
  66722. * @returns The radial explosion event data
  66723. */
  66724. getData(): PhysicsRadialExplosionEventData;
  66725. /**
  66726. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66727. * @param impostor A physics imposter
  66728. * @param origin the origin of the explosion
  66729. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66730. */
  66731. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66732. /**
  66733. * Triggers affecterd impostors callbacks
  66734. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66735. */
  66736. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66737. /**
  66738. * Disposes the sphere.
  66739. * @param force Specifies if the sphere should be disposed by force
  66740. */
  66741. dispose(force?: boolean): void;
  66742. /*** Helpers ***/
  66743. private _prepareSphere;
  66744. private _intersectsWithSphere;
  66745. }
  66746. /**
  66747. * Represents a gravitational field event
  66748. */
  66749. class PhysicsGravitationalFieldEvent {
  66750. private _physicsHelper;
  66751. private _scene;
  66752. private _origin;
  66753. private _options;
  66754. private _tickCallback;
  66755. private _sphere;
  66756. private _dataFetched;
  66757. /**
  66758. * Initializes the physics gravitational field event
  66759. * @param _physicsHelper A physics helper
  66760. * @param _scene BabylonJS scene
  66761. * @param _origin The origin position of the gravitational field event
  66762. * @param _options The options for the vortex event
  66763. */
  66764. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66765. /**
  66766. * Returns the data related to the gravitational field event (sphere).
  66767. * @returns A gravitational field event
  66768. */
  66769. getData(): PhysicsGravitationalFieldEventData;
  66770. /**
  66771. * Enables the gravitational field.
  66772. */
  66773. enable(): void;
  66774. /**
  66775. * Disables the gravitational field.
  66776. */
  66777. disable(): void;
  66778. /**
  66779. * Disposes the sphere.
  66780. * @param force The force to dispose from the gravitational field event
  66781. */
  66782. dispose(force?: boolean): void;
  66783. private _tick;
  66784. }
  66785. /**
  66786. * Represents a physics updraft event
  66787. */
  66788. class PhysicsUpdraftEvent {
  66789. private _scene;
  66790. private _origin;
  66791. private _options;
  66792. private _physicsEngine;
  66793. private _originTop;
  66794. private _originDirection;
  66795. private _tickCallback;
  66796. private _cylinder;
  66797. private _cylinderPosition;
  66798. private _dataFetched;
  66799. /**
  66800. * Initializes the physics updraft event
  66801. * @param _scene BabylonJS scene
  66802. * @param _origin The origin position of the updraft
  66803. * @param _options The options for the updraft event
  66804. */
  66805. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66806. /**
  66807. * Returns the data related to the updraft event (cylinder).
  66808. * @returns A physics updraft event
  66809. */
  66810. getData(): PhysicsUpdraftEventData;
  66811. /**
  66812. * Enables the updraft.
  66813. */
  66814. enable(): void;
  66815. /**
  66816. * Disables the updraft.
  66817. */
  66818. disable(): void;
  66819. /**
  66820. * Disposes the cylinder.
  66821. * @param force Specifies if the updraft should be disposed by force
  66822. */
  66823. dispose(force?: boolean): void;
  66824. private getImpostorHitData;
  66825. private _tick;
  66826. /*** Helpers ***/
  66827. private _prepareCylinder;
  66828. private _intersectsWithCylinder;
  66829. }
  66830. /**
  66831. * Represents a physics vortex event
  66832. */
  66833. class PhysicsVortexEvent {
  66834. private _scene;
  66835. private _origin;
  66836. private _options;
  66837. private _physicsEngine;
  66838. private _originTop;
  66839. private _tickCallback;
  66840. private _cylinder;
  66841. private _cylinderPosition;
  66842. private _dataFetched;
  66843. /**
  66844. * Initializes the physics vortex event
  66845. * @param _scene The BabylonJS scene
  66846. * @param _origin The origin position of the vortex
  66847. * @param _options The options for the vortex event
  66848. */
  66849. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66850. /**
  66851. * Returns the data related to the vortex event (cylinder).
  66852. * @returns The physics vortex event data
  66853. */
  66854. getData(): PhysicsVortexEventData;
  66855. /**
  66856. * Enables the vortex.
  66857. */
  66858. enable(): void;
  66859. /**
  66860. * Disables the cortex.
  66861. */
  66862. disable(): void;
  66863. /**
  66864. * Disposes the sphere.
  66865. * @param force
  66866. */
  66867. dispose(force?: boolean): void;
  66868. private getImpostorHitData;
  66869. private _tick;
  66870. /*** Helpers ***/
  66871. private _prepareCylinder;
  66872. private _intersectsWithCylinder;
  66873. }
  66874. /**
  66875. * Options fot the radial explosion event
  66876. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66877. */
  66878. export class PhysicsRadialExplosionEventOptions {
  66879. /**
  66880. * The radius of the sphere for the radial explosion.
  66881. */
  66882. radius: number;
  66883. /**
  66884. * The strenth of the explosion.
  66885. */
  66886. strength: number;
  66887. /**
  66888. * The strenght of the force in correspondence to the distance of the affected object
  66889. */
  66890. falloff: PhysicsRadialImpulseFalloff;
  66891. /**
  66892. * Sphere options for the radial explosion.
  66893. */
  66894. sphere: {
  66895. segments: number;
  66896. diameter: number;
  66897. };
  66898. /**
  66899. * Sphere options for the radial explosion.
  66900. */
  66901. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66902. }
  66903. /**
  66904. * Options fot the updraft event
  66905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66906. */
  66907. export class PhysicsUpdraftEventOptions {
  66908. /**
  66909. * The radius of the cylinder for the vortex
  66910. */
  66911. radius: number;
  66912. /**
  66913. * The strenth of the updraft.
  66914. */
  66915. strength: number;
  66916. /**
  66917. * The height of the cylinder for the updraft.
  66918. */
  66919. height: number;
  66920. /**
  66921. * The mode for the the updraft.
  66922. */
  66923. updraftMode: PhysicsUpdraftMode;
  66924. }
  66925. /**
  66926. * Options fot the vortex event
  66927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66928. */
  66929. export class PhysicsVortexEventOptions {
  66930. /**
  66931. * The radius of the cylinder for the vortex
  66932. */
  66933. radius: number;
  66934. /**
  66935. * The strenth of the vortex.
  66936. */
  66937. strength: number;
  66938. /**
  66939. * The height of the cylinder for the vortex.
  66940. */
  66941. height: number;
  66942. /**
  66943. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66944. */
  66945. centripetalForceThreshold: number;
  66946. /**
  66947. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66948. */
  66949. centripetalForceMultiplier: number;
  66950. /**
  66951. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66952. */
  66953. centrifugalForceMultiplier: number;
  66954. /**
  66955. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66956. */
  66957. updraftForceMultiplier: number;
  66958. }
  66959. /**
  66960. * The strenght of the force in correspondence to the distance of the affected object
  66961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66962. */
  66963. export enum PhysicsRadialImpulseFalloff {
  66964. /** Defines that impulse is constant in strength across it's whole radius */
  66965. Constant = 0,
  66966. /** Defines that impulse gets weaker if it's further from the origin */
  66967. Linear = 1
  66968. }
  66969. /**
  66970. * The strength of the force in correspondence to the distance of the affected object
  66971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66972. */
  66973. export enum PhysicsUpdraftMode {
  66974. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66975. Center = 0,
  66976. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66977. Perpendicular = 1
  66978. }
  66979. /**
  66980. * Interface for a physics hit data
  66981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66982. */
  66983. export interface PhysicsHitData {
  66984. /**
  66985. * The force applied at the contact point
  66986. */
  66987. force: Vector3;
  66988. /**
  66989. * The contact point
  66990. */
  66991. contactPoint: Vector3;
  66992. /**
  66993. * The distance from the origin to the contact point
  66994. */
  66995. distanceFromOrigin: number;
  66996. }
  66997. /**
  66998. * Interface for radial explosion event data
  66999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67000. */
  67001. export interface PhysicsRadialExplosionEventData {
  67002. /**
  67003. * A sphere used for the radial explosion event
  67004. */
  67005. sphere: Mesh;
  67006. }
  67007. /**
  67008. * Interface for gravitational field event data
  67009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67010. */
  67011. export interface PhysicsGravitationalFieldEventData {
  67012. /**
  67013. * A sphere mesh used for the gravitational field event
  67014. */
  67015. sphere: Mesh;
  67016. }
  67017. /**
  67018. * Interface for updraft event data
  67019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67020. */
  67021. export interface PhysicsUpdraftEventData {
  67022. /**
  67023. * A cylinder used for the updraft event
  67024. */
  67025. cylinder: Mesh;
  67026. }
  67027. /**
  67028. * Interface for vortex event data
  67029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67030. */
  67031. export interface PhysicsVortexEventData {
  67032. /**
  67033. * A cylinder used for the vortex event
  67034. */
  67035. cylinder: Mesh;
  67036. }
  67037. /**
  67038. * Interface for an affected physics impostor
  67039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67040. */
  67041. export interface PhysicsAffectedImpostorWithData {
  67042. /**
  67043. * The impostor affected by the effect
  67044. */
  67045. impostor: PhysicsImpostor;
  67046. /**
  67047. * The data about the hit/horce from the explosion
  67048. */
  67049. hitData: PhysicsHitData;
  67050. }
  67051. }
  67052. declare module BABYLON {
  67053. /** @hidden */
  67054. export var blackAndWhitePixelShader: {
  67055. name: string;
  67056. shader: string;
  67057. };
  67058. }
  67059. declare module BABYLON {
  67060. /**
  67061. * Post process used to render in black and white
  67062. */
  67063. export class BlackAndWhitePostProcess extends PostProcess {
  67064. /**
  67065. * Linear about to convert he result to black and white (default: 1)
  67066. */
  67067. degree: number;
  67068. /**
  67069. * Creates a black and white post process
  67070. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67071. * @param name The name of the effect.
  67072. * @param options The required width/height ratio to downsize to before computing the render pass.
  67073. * @param camera The camera to apply the render pass to.
  67074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67075. * @param engine The engine which the post process will be applied. (default: current engine)
  67076. * @param reusable If the post process can be reused on the same frame. (default: false)
  67077. */
  67078. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67079. }
  67080. }
  67081. declare module BABYLON {
  67082. /**
  67083. * This represents a set of one or more post processes in Babylon.
  67084. * A post process can be used to apply a shader to a texture after it is rendered.
  67085. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67086. */
  67087. export class PostProcessRenderEffect {
  67088. private _postProcesses;
  67089. private _getPostProcesses;
  67090. private _singleInstance;
  67091. private _cameras;
  67092. private _indicesForCamera;
  67093. /**
  67094. * Name of the effect
  67095. * @hidden
  67096. */
  67097. _name: string;
  67098. /**
  67099. * Instantiates a post process render effect.
  67100. * A post process can be used to apply a shader to a texture after it is rendered.
  67101. * @param engine The engine the effect is tied to
  67102. * @param name The name of the effect
  67103. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67104. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67105. */
  67106. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67107. /**
  67108. * Checks if all the post processes in the effect are supported.
  67109. */
  67110. get isSupported(): boolean;
  67111. /**
  67112. * Updates the current state of the effect
  67113. * @hidden
  67114. */
  67115. _update(): void;
  67116. /**
  67117. * Attaches the effect on cameras
  67118. * @param cameras The camera to attach to.
  67119. * @hidden
  67120. */
  67121. _attachCameras(cameras: Camera): void;
  67122. /**
  67123. * Attaches the effect on cameras
  67124. * @param cameras The camera to attach to.
  67125. * @hidden
  67126. */
  67127. _attachCameras(cameras: Camera[]): void;
  67128. /**
  67129. * Detaches the effect on cameras
  67130. * @param cameras The camera to detatch from.
  67131. * @hidden
  67132. */
  67133. _detachCameras(cameras: Camera): void;
  67134. /**
  67135. * Detatches the effect on cameras
  67136. * @param cameras The camera to detatch from.
  67137. * @hidden
  67138. */
  67139. _detachCameras(cameras: Camera[]): void;
  67140. /**
  67141. * Enables the effect on given cameras
  67142. * @param cameras The camera to enable.
  67143. * @hidden
  67144. */
  67145. _enable(cameras: Camera): void;
  67146. /**
  67147. * Enables the effect on given cameras
  67148. * @param cameras The camera to enable.
  67149. * @hidden
  67150. */
  67151. _enable(cameras: Nullable<Camera[]>): void;
  67152. /**
  67153. * Disables the effect on the given cameras
  67154. * @param cameras The camera to disable.
  67155. * @hidden
  67156. */
  67157. _disable(cameras: Camera): void;
  67158. /**
  67159. * Disables the effect on the given cameras
  67160. * @param cameras The camera to disable.
  67161. * @hidden
  67162. */
  67163. _disable(cameras: Nullable<Camera[]>): void;
  67164. /**
  67165. * Gets a list of the post processes contained in the effect.
  67166. * @param camera The camera to get the post processes on.
  67167. * @returns The list of the post processes in the effect.
  67168. */
  67169. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67170. }
  67171. }
  67172. declare module BABYLON {
  67173. /** @hidden */
  67174. export var extractHighlightsPixelShader: {
  67175. name: string;
  67176. shader: string;
  67177. };
  67178. }
  67179. declare module BABYLON {
  67180. /**
  67181. * 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.
  67182. */
  67183. export class ExtractHighlightsPostProcess extends PostProcess {
  67184. /**
  67185. * The luminance threshold, pixels below this value will be set to black.
  67186. */
  67187. threshold: number;
  67188. /** @hidden */
  67189. _exposure: number;
  67190. /**
  67191. * Post process which has the input texture to be used when performing highlight extraction
  67192. * @hidden
  67193. */
  67194. _inputPostProcess: Nullable<PostProcess>;
  67195. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67196. }
  67197. }
  67198. declare module BABYLON {
  67199. /** @hidden */
  67200. export var bloomMergePixelShader: {
  67201. name: string;
  67202. shader: string;
  67203. };
  67204. }
  67205. declare module BABYLON {
  67206. /**
  67207. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67208. */
  67209. export class BloomMergePostProcess extends PostProcess {
  67210. /** Weight of the bloom to be added to the original input. */
  67211. weight: number;
  67212. /**
  67213. * Creates a new instance of @see BloomMergePostProcess
  67214. * @param name The name of the effect.
  67215. * @param originalFromInput Post process which's input will be used for the merge.
  67216. * @param blurred Blurred highlights post process which's output will be used.
  67217. * @param weight Weight of the bloom to be added to the original input.
  67218. * @param options The required width/height ratio to downsize to before computing the render pass.
  67219. * @param camera The camera to apply the render pass to.
  67220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67221. * @param engine The engine which the post process will be applied. (default: current engine)
  67222. * @param reusable If the post process can be reused on the same frame. (default: false)
  67223. * @param textureType Type of textures used when performing the post process. (default: 0)
  67224. * @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)
  67225. */
  67226. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67227. /** Weight of the bloom to be added to the original input. */
  67228. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67229. }
  67230. }
  67231. declare module BABYLON {
  67232. /**
  67233. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67234. */
  67235. export class BloomEffect extends PostProcessRenderEffect {
  67236. private bloomScale;
  67237. /**
  67238. * @hidden Internal
  67239. */
  67240. _effects: Array<PostProcess>;
  67241. /**
  67242. * @hidden Internal
  67243. */
  67244. _downscale: ExtractHighlightsPostProcess;
  67245. private _blurX;
  67246. private _blurY;
  67247. private _merge;
  67248. /**
  67249. * The luminance threshold to find bright areas of the image to bloom.
  67250. */
  67251. get threshold(): number;
  67252. set threshold(value: number);
  67253. /**
  67254. * The strength of the bloom.
  67255. */
  67256. get weight(): number;
  67257. set weight(value: number);
  67258. /**
  67259. * Specifies the size of the bloom blur kernel, relative to the final output size
  67260. */
  67261. get kernel(): number;
  67262. set kernel(value: number);
  67263. /**
  67264. * Creates a new instance of @see BloomEffect
  67265. * @param scene The scene the effect belongs to.
  67266. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67267. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67268. * @param bloomWeight The the strength of bloom.
  67269. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67270. * @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)
  67271. */
  67272. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67273. /**
  67274. * Disposes each of the internal effects for a given camera.
  67275. * @param camera The camera to dispose the effect on.
  67276. */
  67277. disposeEffects(camera: Camera): void;
  67278. /**
  67279. * @hidden Internal
  67280. */
  67281. _updateEffects(): void;
  67282. /**
  67283. * Internal
  67284. * @returns if all the contained post processes are ready.
  67285. * @hidden
  67286. */
  67287. _isReady(): boolean;
  67288. }
  67289. }
  67290. declare module BABYLON {
  67291. /** @hidden */
  67292. export var chromaticAberrationPixelShader: {
  67293. name: string;
  67294. shader: string;
  67295. };
  67296. }
  67297. declare module BABYLON {
  67298. /**
  67299. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67300. */
  67301. export class ChromaticAberrationPostProcess extends PostProcess {
  67302. /**
  67303. * The amount of seperation of rgb channels (default: 30)
  67304. */
  67305. aberrationAmount: number;
  67306. /**
  67307. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67308. */
  67309. radialIntensity: number;
  67310. /**
  67311. * 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))
  67312. */
  67313. direction: Vector2;
  67314. /**
  67315. * 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))
  67316. */
  67317. centerPosition: Vector2;
  67318. /**
  67319. * Creates a new instance ChromaticAberrationPostProcess
  67320. * @param name The name of the effect.
  67321. * @param screenWidth The width of the screen to apply the effect on.
  67322. * @param screenHeight The height of the screen to apply the effect on.
  67323. * @param options The required width/height ratio to downsize to before computing the render pass.
  67324. * @param camera The camera to apply the render pass to.
  67325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67326. * @param engine The engine which the post process will be applied. (default: current engine)
  67327. * @param reusable If the post process can be reused on the same frame. (default: false)
  67328. * @param textureType Type of textures used when performing the post process. (default: 0)
  67329. * @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)
  67330. */
  67331. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67332. }
  67333. }
  67334. declare module BABYLON {
  67335. /** @hidden */
  67336. export var circleOfConfusionPixelShader: {
  67337. name: string;
  67338. shader: string;
  67339. };
  67340. }
  67341. declare module BABYLON {
  67342. /**
  67343. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67344. */
  67345. export class CircleOfConfusionPostProcess extends PostProcess {
  67346. /**
  67347. * 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.
  67348. */
  67349. lensSize: number;
  67350. /**
  67351. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67352. */
  67353. fStop: number;
  67354. /**
  67355. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67356. */
  67357. focusDistance: number;
  67358. /**
  67359. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67360. */
  67361. focalLength: number;
  67362. private _depthTexture;
  67363. /**
  67364. * Creates a new instance CircleOfConfusionPostProcess
  67365. * @param name The name of the effect.
  67366. * @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.
  67367. * @param options The required width/height ratio to downsize to before computing the render pass.
  67368. * @param camera The camera to apply the render pass to.
  67369. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67370. * @param engine The engine which the post process will be applied. (default: current engine)
  67371. * @param reusable If the post process can be reused on the same frame. (default: false)
  67372. * @param textureType Type of textures used when performing the post process. (default: 0)
  67373. * @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)
  67374. */
  67375. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67376. /**
  67377. * 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.
  67378. */
  67379. set depthTexture(value: RenderTargetTexture);
  67380. }
  67381. }
  67382. declare module BABYLON {
  67383. /** @hidden */
  67384. export var colorCorrectionPixelShader: {
  67385. name: string;
  67386. shader: string;
  67387. };
  67388. }
  67389. declare module BABYLON {
  67390. /**
  67391. *
  67392. * This post-process allows the modification of rendered colors by using
  67393. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67394. *
  67395. * The object needs to be provided an url to a texture containing the color
  67396. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67397. * Use an image editing software to tweak the LUT to match your needs.
  67398. *
  67399. * For an example of a color LUT, see here:
  67400. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67401. * For explanations on color grading, see here:
  67402. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67403. *
  67404. */
  67405. export class ColorCorrectionPostProcess extends PostProcess {
  67406. private _colorTableTexture;
  67407. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67408. }
  67409. }
  67410. declare module BABYLON {
  67411. /** @hidden */
  67412. export var convolutionPixelShader: {
  67413. name: string;
  67414. shader: string;
  67415. };
  67416. }
  67417. declare module BABYLON {
  67418. /**
  67419. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67420. * input texture to perform effects such as edge detection or sharpening
  67421. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67422. */
  67423. export class ConvolutionPostProcess extends PostProcess {
  67424. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67425. kernel: number[];
  67426. /**
  67427. * Creates a new instance ConvolutionPostProcess
  67428. * @param name The name of the effect.
  67429. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67430. * @param options The required width/height ratio to downsize to before computing the render pass.
  67431. * @param camera The camera to apply the render pass to.
  67432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67433. * @param engine The engine which the post process will be applied. (default: current engine)
  67434. * @param reusable If the post process can be reused on the same frame. (default: false)
  67435. * @param textureType Type of textures used when performing the post process. (default: 0)
  67436. */
  67437. constructor(name: string,
  67438. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67439. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67440. /**
  67441. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67442. */
  67443. static EdgeDetect0Kernel: number[];
  67444. /**
  67445. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67446. */
  67447. static EdgeDetect1Kernel: number[];
  67448. /**
  67449. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67450. */
  67451. static EdgeDetect2Kernel: number[];
  67452. /**
  67453. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67454. */
  67455. static SharpenKernel: number[];
  67456. /**
  67457. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67458. */
  67459. static EmbossKernel: number[];
  67460. /**
  67461. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67462. */
  67463. static GaussianKernel: number[];
  67464. }
  67465. }
  67466. declare module BABYLON {
  67467. /**
  67468. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67469. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67470. * based on samples that have a large difference in distance than the center pixel.
  67471. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67472. */
  67473. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67474. direction: Vector2;
  67475. /**
  67476. * Creates a new instance CircleOfConfusionPostProcess
  67477. * @param name The name of the effect.
  67478. * @param scene The scene the effect belongs to.
  67479. * @param direction The direction the blur should be applied.
  67480. * @param kernel The size of the kernel used to blur.
  67481. * @param options The required width/height ratio to downsize to before computing the render pass.
  67482. * @param camera The camera to apply the render pass to.
  67483. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67484. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67486. * @param engine The engine which the post process will be applied. (default: current engine)
  67487. * @param reusable If the post process can be reused on the same frame. (default: false)
  67488. * @param textureType Type of textures used when performing the post process. (default: 0)
  67489. * @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)
  67490. */
  67491. 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);
  67492. }
  67493. }
  67494. declare module BABYLON {
  67495. /** @hidden */
  67496. export var depthOfFieldMergePixelShader: {
  67497. name: string;
  67498. shader: string;
  67499. };
  67500. }
  67501. declare module BABYLON {
  67502. /**
  67503. * Options to be set when merging outputs from the default pipeline.
  67504. */
  67505. export class DepthOfFieldMergePostProcessOptions {
  67506. /**
  67507. * The original image to merge on top of
  67508. */
  67509. originalFromInput: PostProcess;
  67510. /**
  67511. * Parameters to perform the merge of the depth of field effect
  67512. */
  67513. depthOfField?: {
  67514. circleOfConfusion: PostProcess;
  67515. blurSteps: Array<PostProcess>;
  67516. };
  67517. /**
  67518. * Parameters to perform the merge of bloom effect
  67519. */
  67520. bloom?: {
  67521. blurred: PostProcess;
  67522. weight: number;
  67523. };
  67524. }
  67525. /**
  67526. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67527. */
  67528. export class DepthOfFieldMergePostProcess extends PostProcess {
  67529. private blurSteps;
  67530. /**
  67531. * Creates a new instance of DepthOfFieldMergePostProcess
  67532. * @param name The name of the effect.
  67533. * @param originalFromInput Post process which's input will be used for the merge.
  67534. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67535. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67536. * @param options The required width/height ratio to downsize to before computing the render pass.
  67537. * @param camera The camera to apply the render pass to.
  67538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67539. * @param engine The engine which the post process will be applied. (default: current engine)
  67540. * @param reusable If the post process can be reused on the same frame. (default: false)
  67541. * @param textureType Type of textures used when performing the post process. (default: 0)
  67542. * @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)
  67543. */
  67544. 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);
  67545. /**
  67546. * Updates the effect with the current post process compile time values and recompiles the shader.
  67547. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67548. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67549. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67550. * @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
  67551. * @param onCompiled Called when the shader has been compiled.
  67552. * @param onError Called if there is an error when compiling a shader.
  67553. */
  67554. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67555. }
  67556. }
  67557. declare module BABYLON {
  67558. /**
  67559. * Specifies the level of max blur that should be applied when using the depth of field effect
  67560. */
  67561. export enum DepthOfFieldEffectBlurLevel {
  67562. /**
  67563. * Subtle blur
  67564. */
  67565. Low = 0,
  67566. /**
  67567. * Medium blur
  67568. */
  67569. Medium = 1,
  67570. /**
  67571. * Large blur
  67572. */
  67573. High = 2
  67574. }
  67575. /**
  67576. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67577. */
  67578. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67579. private _circleOfConfusion;
  67580. /**
  67581. * @hidden Internal, blurs from high to low
  67582. */
  67583. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67584. private _depthOfFieldBlurY;
  67585. private _dofMerge;
  67586. /**
  67587. * @hidden Internal post processes in depth of field effect
  67588. */
  67589. _effects: Array<PostProcess>;
  67590. /**
  67591. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67592. */
  67593. set focalLength(value: number);
  67594. get focalLength(): number;
  67595. /**
  67596. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67597. */
  67598. set fStop(value: number);
  67599. get fStop(): number;
  67600. /**
  67601. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67602. */
  67603. set focusDistance(value: number);
  67604. get focusDistance(): number;
  67605. /**
  67606. * 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.
  67607. */
  67608. set lensSize(value: number);
  67609. get lensSize(): number;
  67610. /**
  67611. * Creates a new instance DepthOfFieldEffect
  67612. * @param scene The scene the effect belongs to.
  67613. * @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.
  67614. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67615. * @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)
  67616. */
  67617. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67618. /**
  67619. * Get the current class name of the current effet
  67620. * @returns "DepthOfFieldEffect"
  67621. */
  67622. getClassName(): string;
  67623. /**
  67624. * 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.
  67625. */
  67626. set depthTexture(value: RenderTargetTexture);
  67627. /**
  67628. * Disposes each of the internal effects for a given camera.
  67629. * @param camera The camera to dispose the effect on.
  67630. */
  67631. disposeEffects(camera: Camera): void;
  67632. /**
  67633. * @hidden Internal
  67634. */
  67635. _updateEffects(): void;
  67636. /**
  67637. * Internal
  67638. * @returns if all the contained post processes are ready.
  67639. * @hidden
  67640. */
  67641. _isReady(): boolean;
  67642. }
  67643. }
  67644. declare module BABYLON {
  67645. /** @hidden */
  67646. export var displayPassPixelShader: {
  67647. name: string;
  67648. shader: string;
  67649. };
  67650. }
  67651. declare module BABYLON {
  67652. /**
  67653. * DisplayPassPostProcess which produces an output the same as it's input
  67654. */
  67655. export class DisplayPassPostProcess extends PostProcess {
  67656. /**
  67657. * Creates the DisplayPassPostProcess
  67658. * @param name The name of the effect.
  67659. * @param options The required width/height ratio to downsize to before computing the render pass.
  67660. * @param camera The camera to apply the render pass to.
  67661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67662. * @param engine The engine which the post process will be applied. (default: current engine)
  67663. * @param reusable If the post process can be reused on the same frame. (default: false)
  67664. */
  67665. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67666. }
  67667. }
  67668. declare module BABYLON {
  67669. /** @hidden */
  67670. export var filterPixelShader: {
  67671. name: string;
  67672. shader: string;
  67673. };
  67674. }
  67675. declare module BABYLON {
  67676. /**
  67677. * Applies a kernel filter to the image
  67678. */
  67679. export class FilterPostProcess extends PostProcess {
  67680. /** The matrix to be applied to the image */
  67681. kernelMatrix: Matrix;
  67682. /**
  67683. *
  67684. * @param name The name of the effect.
  67685. * @param kernelMatrix The matrix to be applied to the image
  67686. * @param options The required width/height ratio to downsize to before computing the render pass.
  67687. * @param camera The camera to apply the render pass to.
  67688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67689. * @param engine The engine which the post process will be applied. (default: current engine)
  67690. * @param reusable If the post process can be reused on the same frame. (default: false)
  67691. */
  67692. constructor(name: string,
  67693. /** The matrix to be applied to the image */
  67694. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67695. }
  67696. }
  67697. declare module BABYLON {
  67698. /** @hidden */
  67699. export var fxaaPixelShader: {
  67700. name: string;
  67701. shader: string;
  67702. };
  67703. }
  67704. declare module BABYLON {
  67705. /** @hidden */
  67706. export var fxaaVertexShader: {
  67707. name: string;
  67708. shader: string;
  67709. };
  67710. }
  67711. declare module BABYLON {
  67712. /**
  67713. * Fxaa post process
  67714. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67715. */
  67716. export class FxaaPostProcess extends PostProcess {
  67717. /** @hidden */
  67718. texelWidth: number;
  67719. /** @hidden */
  67720. texelHeight: number;
  67721. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67722. private _getDefines;
  67723. }
  67724. }
  67725. declare module BABYLON {
  67726. /** @hidden */
  67727. export var grainPixelShader: {
  67728. name: string;
  67729. shader: string;
  67730. };
  67731. }
  67732. declare module BABYLON {
  67733. /**
  67734. * The GrainPostProcess adds noise to the image at mid luminance levels
  67735. */
  67736. export class GrainPostProcess extends PostProcess {
  67737. /**
  67738. * The intensity of the grain added (default: 30)
  67739. */
  67740. intensity: number;
  67741. /**
  67742. * If the grain should be randomized on every frame
  67743. */
  67744. animated: boolean;
  67745. /**
  67746. * Creates a new instance of @see GrainPostProcess
  67747. * @param name The name of the effect.
  67748. * @param options The required width/height ratio to downsize to before computing the render pass.
  67749. * @param camera The camera to apply the render pass to.
  67750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67751. * @param engine The engine which the post process will be applied. (default: current engine)
  67752. * @param reusable If the post process can be reused on the same frame. (default: false)
  67753. * @param textureType Type of textures used when performing the post process. (default: 0)
  67754. * @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)
  67755. */
  67756. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67757. }
  67758. }
  67759. declare module BABYLON {
  67760. /** @hidden */
  67761. export var highlightsPixelShader: {
  67762. name: string;
  67763. shader: string;
  67764. };
  67765. }
  67766. declare module BABYLON {
  67767. /**
  67768. * Extracts highlights from the image
  67769. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67770. */
  67771. export class HighlightsPostProcess extends PostProcess {
  67772. /**
  67773. * Extracts highlights from the image
  67774. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67775. * @param name The name of the effect.
  67776. * @param options The required width/height ratio to downsize to before computing the render pass.
  67777. * @param camera The camera to apply the render pass to.
  67778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67779. * @param engine The engine which the post process will be applied. (default: current engine)
  67780. * @param reusable If the post process can be reused on the same frame. (default: false)
  67781. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67782. */
  67783. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67784. }
  67785. }
  67786. declare module BABYLON {
  67787. /** @hidden */
  67788. export var mrtFragmentDeclaration: {
  67789. name: string;
  67790. shader: string;
  67791. };
  67792. }
  67793. declare module BABYLON {
  67794. /** @hidden */
  67795. export var geometryPixelShader: {
  67796. name: string;
  67797. shader: string;
  67798. };
  67799. }
  67800. declare module BABYLON {
  67801. /** @hidden */
  67802. export var geometryVertexShader: {
  67803. name: string;
  67804. shader: string;
  67805. };
  67806. }
  67807. declare module BABYLON {
  67808. /** @hidden */
  67809. interface ISavedTransformationMatrix {
  67810. world: Matrix;
  67811. viewProjection: Matrix;
  67812. }
  67813. /**
  67814. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67815. */
  67816. export class GeometryBufferRenderer {
  67817. /**
  67818. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67819. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67820. */
  67821. static readonly POSITION_TEXTURE_TYPE: number;
  67822. /**
  67823. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67824. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67825. */
  67826. static readonly VELOCITY_TEXTURE_TYPE: number;
  67827. /**
  67828. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67829. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67830. */
  67831. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67832. /**
  67833. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67834. * in order to compute objects velocities when enableVelocity is set to "true"
  67835. * @hidden
  67836. */
  67837. _previousTransformationMatrices: {
  67838. [index: number]: ISavedTransformationMatrix;
  67839. };
  67840. /**
  67841. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67842. * in order to compute objects velocities when enableVelocity is set to "true"
  67843. * @hidden
  67844. */
  67845. _previousBonesTransformationMatrices: {
  67846. [index: number]: Float32Array;
  67847. };
  67848. /**
  67849. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67850. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67851. */
  67852. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67853. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67854. renderTransparentMeshes: boolean;
  67855. private _scene;
  67856. private _multiRenderTarget;
  67857. private _ratio;
  67858. private _enablePosition;
  67859. private _enableVelocity;
  67860. private _enableReflectivity;
  67861. private _positionIndex;
  67862. private _velocityIndex;
  67863. private _reflectivityIndex;
  67864. protected _effect: Effect;
  67865. protected _cachedDefines: string;
  67866. /**
  67867. * Set the render list (meshes to be rendered) used in the G buffer.
  67868. */
  67869. set renderList(meshes: Mesh[]);
  67870. /**
  67871. * Gets wether or not G buffer are supported by the running hardware.
  67872. * This requires draw buffer supports
  67873. */
  67874. get isSupported(): boolean;
  67875. /**
  67876. * Returns the index of the given texture type in the G-Buffer textures array
  67877. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  67878. * @returns the index of the given texture type in the G-Buffer textures array
  67879. */
  67880. getTextureIndex(textureType: number): number;
  67881. /**
  67882. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  67883. */
  67884. get enablePosition(): boolean;
  67885. /**
  67886. * Sets whether or not objects positions are enabled for the G buffer.
  67887. */
  67888. set enablePosition(enable: boolean);
  67889. /**
  67890. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  67891. */
  67892. get enableVelocity(): boolean;
  67893. /**
  67894. * Sets wether or not objects velocities are enabled for the G buffer.
  67895. */
  67896. set enableVelocity(enable: boolean);
  67897. /**
  67898. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  67899. */
  67900. get enableReflectivity(): boolean;
  67901. /**
  67902. * Sets wether or not objects roughness are enabled for the G buffer.
  67903. */
  67904. set enableReflectivity(enable: boolean);
  67905. /**
  67906. * Gets the scene associated with the buffer.
  67907. */
  67908. get scene(): Scene;
  67909. /**
  67910. * Gets the ratio used by the buffer during its creation.
  67911. * How big is the buffer related to the main canvas.
  67912. */
  67913. get ratio(): number;
  67914. /** @hidden */
  67915. static _SceneComponentInitialization: (scene: Scene) => void;
  67916. /**
  67917. * Creates a new G Buffer for the scene
  67918. * @param scene The scene the buffer belongs to
  67919. * @param ratio How big is the buffer related to the main canvas.
  67920. */
  67921. constructor(scene: Scene, ratio?: number);
  67922. /**
  67923. * Checks wether everything is ready to render a submesh to the G buffer.
  67924. * @param subMesh the submesh to check readiness for
  67925. * @param useInstances is the mesh drawn using instance or not
  67926. * @returns true if ready otherwise false
  67927. */
  67928. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67929. /**
  67930. * Gets the current underlying G Buffer.
  67931. * @returns the buffer
  67932. */
  67933. getGBuffer(): MultiRenderTarget;
  67934. /**
  67935. * Gets the number of samples used to render the buffer (anti aliasing).
  67936. */
  67937. get samples(): number;
  67938. /**
  67939. * Sets the number of samples used to render the buffer (anti aliasing).
  67940. */
  67941. set samples(value: number);
  67942. /**
  67943. * Disposes the renderer and frees up associated resources.
  67944. */
  67945. dispose(): void;
  67946. protected _createRenderTargets(): void;
  67947. private _copyBonesTransformationMatrices;
  67948. }
  67949. }
  67950. declare module BABYLON {
  67951. interface Scene {
  67952. /** @hidden (Backing field) */
  67953. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67954. /**
  67955. * Gets or Sets the current geometry buffer associated to the scene.
  67956. */
  67957. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67958. /**
  67959. * Enables a GeometryBufferRender and associates it with the scene
  67960. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  67961. * @returns the GeometryBufferRenderer
  67962. */
  67963. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  67964. /**
  67965. * Disables the GeometryBufferRender associated with the scene
  67966. */
  67967. disableGeometryBufferRenderer(): void;
  67968. }
  67969. /**
  67970. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  67971. * in several rendering techniques.
  67972. */
  67973. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  67974. /**
  67975. * The component name helpful to identify the component in the list of scene components.
  67976. */
  67977. readonly name: string;
  67978. /**
  67979. * The scene the component belongs to.
  67980. */
  67981. scene: Scene;
  67982. /**
  67983. * Creates a new instance of the component for the given scene
  67984. * @param scene Defines the scene to register the component in
  67985. */
  67986. constructor(scene: Scene);
  67987. /**
  67988. * Registers the component in a given scene
  67989. */
  67990. register(): void;
  67991. /**
  67992. * Rebuilds the elements related to this component in case of
  67993. * context lost for instance.
  67994. */
  67995. rebuild(): void;
  67996. /**
  67997. * Disposes the component and the associated ressources
  67998. */
  67999. dispose(): void;
  68000. private _gatherRenderTargets;
  68001. }
  68002. }
  68003. declare module BABYLON {
  68004. /** @hidden */
  68005. export var motionBlurPixelShader: {
  68006. name: string;
  68007. shader: string;
  68008. };
  68009. }
  68010. declare module BABYLON {
  68011. /**
  68012. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68013. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68014. * As an example, all you have to do is to create the post-process:
  68015. * var mb = new BABYLON.MotionBlurPostProcess(
  68016. * 'mb', // The name of the effect.
  68017. * scene, // The scene containing the objects to blur according to their velocity.
  68018. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68019. * camera // The camera to apply the render pass to.
  68020. * );
  68021. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68022. */
  68023. export class MotionBlurPostProcess extends PostProcess {
  68024. /**
  68025. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68026. */
  68027. motionStrength: number;
  68028. /**
  68029. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68030. */
  68031. get motionBlurSamples(): number;
  68032. /**
  68033. * Sets the number of iterations to be used for motion blur quality
  68034. */
  68035. set motionBlurSamples(samples: number);
  68036. private _motionBlurSamples;
  68037. private _geometryBufferRenderer;
  68038. /**
  68039. * Creates a new instance MotionBlurPostProcess
  68040. * @param name The name of the effect.
  68041. * @param scene The scene containing the objects to blur according to their velocity.
  68042. * @param options The required width/height ratio to downsize to before computing the render pass.
  68043. * @param camera The camera to apply the render pass to.
  68044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68045. * @param engine The engine which the post process will be applied. (default: current engine)
  68046. * @param reusable If the post process can be reused on the same frame. (default: false)
  68047. * @param textureType Type of textures used when performing the post process. (default: 0)
  68048. * @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)
  68049. */
  68050. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68051. /**
  68052. * Excludes the given skinned mesh from computing bones velocities.
  68053. * 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.
  68054. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68055. */
  68056. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68057. /**
  68058. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68059. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68060. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68061. */
  68062. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68063. /**
  68064. * Disposes the post process.
  68065. * @param camera The camera to dispose the post process on.
  68066. */
  68067. dispose(camera?: Camera): void;
  68068. }
  68069. }
  68070. declare module BABYLON {
  68071. /** @hidden */
  68072. export var refractionPixelShader: {
  68073. name: string;
  68074. shader: string;
  68075. };
  68076. }
  68077. declare module BABYLON {
  68078. /**
  68079. * Post process which applies a refractin texture
  68080. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68081. */
  68082. export class RefractionPostProcess extends PostProcess {
  68083. /** the base color of the refraction (used to taint the rendering) */
  68084. color: Color3;
  68085. /** simulated refraction depth */
  68086. depth: number;
  68087. /** the coefficient of the base color (0 to remove base color tainting) */
  68088. colorLevel: number;
  68089. private _refTexture;
  68090. private _ownRefractionTexture;
  68091. /**
  68092. * Gets or sets the refraction texture
  68093. * Please note that you are responsible for disposing the texture if you set it manually
  68094. */
  68095. get refractionTexture(): Texture;
  68096. set refractionTexture(value: Texture);
  68097. /**
  68098. * Initializes the RefractionPostProcess
  68099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68100. * @param name The name of the effect.
  68101. * @param refractionTextureUrl Url of the refraction texture to use
  68102. * @param color the base color of the refraction (used to taint the rendering)
  68103. * @param depth simulated refraction depth
  68104. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68105. * @param camera The camera to apply the render pass to.
  68106. * @param options The required width/height ratio to downsize to before computing the render pass.
  68107. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68108. * @param engine The engine which the post process will be applied. (default: current engine)
  68109. * @param reusable If the post process can be reused on the same frame. (default: false)
  68110. */
  68111. constructor(name: string, refractionTextureUrl: string,
  68112. /** the base color of the refraction (used to taint the rendering) */
  68113. color: Color3,
  68114. /** simulated refraction depth */
  68115. depth: number,
  68116. /** the coefficient of the base color (0 to remove base color tainting) */
  68117. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68118. /**
  68119. * Disposes of the post process
  68120. * @param camera Camera to dispose post process on
  68121. */
  68122. dispose(camera: Camera): void;
  68123. }
  68124. }
  68125. declare module BABYLON {
  68126. /** @hidden */
  68127. export var sharpenPixelShader: {
  68128. name: string;
  68129. shader: string;
  68130. };
  68131. }
  68132. declare module BABYLON {
  68133. /**
  68134. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68135. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68136. */
  68137. export class SharpenPostProcess extends PostProcess {
  68138. /**
  68139. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68140. */
  68141. colorAmount: number;
  68142. /**
  68143. * How much sharpness should be applied (default: 0.3)
  68144. */
  68145. edgeAmount: number;
  68146. /**
  68147. * Creates a new instance ConvolutionPostProcess
  68148. * @param name The name of the effect.
  68149. * @param options The required width/height ratio to downsize to before computing the render pass.
  68150. * @param camera The camera to apply the render pass to.
  68151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68152. * @param engine The engine which the post process will be applied. (default: current engine)
  68153. * @param reusable If the post process can be reused on the same frame. (default: false)
  68154. * @param textureType Type of textures used when performing the post process. (default: 0)
  68155. * @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)
  68156. */
  68157. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68158. }
  68159. }
  68160. declare module BABYLON {
  68161. /**
  68162. * PostProcessRenderPipeline
  68163. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68164. */
  68165. export class PostProcessRenderPipeline {
  68166. private engine;
  68167. private _renderEffects;
  68168. private _renderEffectsForIsolatedPass;
  68169. /**
  68170. * List of inspectable custom properties (used by the Inspector)
  68171. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68172. */
  68173. inspectableCustomProperties: IInspectable[];
  68174. /**
  68175. * @hidden
  68176. */
  68177. protected _cameras: Camera[];
  68178. /** @hidden */
  68179. _name: string;
  68180. /**
  68181. * Gets pipeline name
  68182. */
  68183. get name(): string;
  68184. /** Gets the list of attached cameras */
  68185. get cameras(): Camera[];
  68186. /**
  68187. * Initializes a PostProcessRenderPipeline
  68188. * @param engine engine to add the pipeline to
  68189. * @param name name of the pipeline
  68190. */
  68191. constructor(engine: Engine, name: string);
  68192. /**
  68193. * Gets the class name
  68194. * @returns "PostProcessRenderPipeline"
  68195. */
  68196. getClassName(): string;
  68197. /**
  68198. * If all the render effects in the pipeline are supported
  68199. */
  68200. get isSupported(): boolean;
  68201. /**
  68202. * Adds an effect to the pipeline
  68203. * @param renderEffect the effect to add
  68204. */
  68205. addEffect(renderEffect: PostProcessRenderEffect): void;
  68206. /** @hidden */
  68207. _rebuild(): void;
  68208. /** @hidden */
  68209. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68210. /** @hidden */
  68211. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68212. /** @hidden */
  68213. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68214. /** @hidden */
  68215. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68216. /** @hidden */
  68217. _attachCameras(cameras: Camera, unique: boolean): void;
  68218. /** @hidden */
  68219. _attachCameras(cameras: Camera[], unique: boolean): void;
  68220. /** @hidden */
  68221. _detachCameras(cameras: Camera): void;
  68222. /** @hidden */
  68223. _detachCameras(cameras: Nullable<Camera[]>): void;
  68224. /** @hidden */
  68225. _update(): void;
  68226. /** @hidden */
  68227. _reset(): void;
  68228. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68229. /**
  68230. * Disposes of the pipeline
  68231. */
  68232. dispose(): void;
  68233. }
  68234. }
  68235. declare module BABYLON {
  68236. /**
  68237. * PostProcessRenderPipelineManager class
  68238. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68239. */
  68240. export class PostProcessRenderPipelineManager {
  68241. private _renderPipelines;
  68242. /**
  68243. * Initializes a PostProcessRenderPipelineManager
  68244. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68245. */
  68246. constructor();
  68247. /**
  68248. * Gets the list of supported render pipelines
  68249. */
  68250. get supportedPipelines(): PostProcessRenderPipeline[];
  68251. /**
  68252. * Adds a pipeline to the manager
  68253. * @param renderPipeline The pipeline to add
  68254. */
  68255. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68256. /**
  68257. * Attaches a camera to the pipeline
  68258. * @param renderPipelineName The name of the pipeline to attach to
  68259. * @param cameras the camera to attach
  68260. * @param unique if the camera can be attached multiple times to the pipeline
  68261. */
  68262. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68263. /**
  68264. * Detaches a camera from the pipeline
  68265. * @param renderPipelineName The name of the pipeline to detach from
  68266. * @param cameras the camera to detach
  68267. */
  68268. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68269. /**
  68270. * Enables an effect by name on a pipeline
  68271. * @param renderPipelineName the name of the pipeline to enable the effect in
  68272. * @param renderEffectName the name of the effect to enable
  68273. * @param cameras the cameras that the effect should be enabled on
  68274. */
  68275. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68276. /**
  68277. * Disables an effect by name on a pipeline
  68278. * @param renderPipelineName the name of the pipeline to disable the effect in
  68279. * @param renderEffectName the name of the effect to disable
  68280. * @param cameras the cameras that the effect should be disabled on
  68281. */
  68282. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68283. /**
  68284. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68285. */
  68286. update(): void;
  68287. /** @hidden */
  68288. _rebuild(): void;
  68289. /**
  68290. * Disposes of the manager and pipelines
  68291. */
  68292. dispose(): void;
  68293. }
  68294. }
  68295. declare module BABYLON {
  68296. interface Scene {
  68297. /** @hidden (Backing field) */
  68298. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68299. /**
  68300. * Gets the postprocess render pipeline manager
  68301. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68302. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68303. */
  68304. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68305. }
  68306. /**
  68307. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68308. */
  68309. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68310. /**
  68311. * The component name helpfull to identify the component in the list of scene components.
  68312. */
  68313. readonly name: string;
  68314. /**
  68315. * The scene the component belongs to.
  68316. */
  68317. scene: Scene;
  68318. /**
  68319. * Creates a new instance of the component for the given scene
  68320. * @param scene Defines the scene to register the component in
  68321. */
  68322. constructor(scene: Scene);
  68323. /**
  68324. * Registers the component in a given scene
  68325. */
  68326. register(): void;
  68327. /**
  68328. * Rebuilds the elements related to this component in case of
  68329. * context lost for instance.
  68330. */
  68331. rebuild(): void;
  68332. /**
  68333. * Disposes the component and the associated ressources
  68334. */
  68335. dispose(): void;
  68336. private _gatherRenderTargets;
  68337. }
  68338. }
  68339. declare module BABYLON {
  68340. /**
  68341. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68342. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68343. */
  68344. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68345. private _scene;
  68346. private _camerasToBeAttached;
  68347. /**
  68348. * ID of the sharpen post process,
  68349. */
  68350. private readonly SharpenPostProcessId;
  68351. /**
  68352. * @ignore
  68353. * ID of the image processing post process;
  68354. */
  68355. readonly ImageProcessingPostProcessId: string;
  68356. /**
  68357. * @ignore
  68358. * ID of the Fast Approximate Anti-Aliasing post process;
  68359. */
  68360. readonly FxaaPostProcessId: string;
  68361. /**
  68362. * ID of the chromatic aberration post process,
  68363. */
  68364. private readonly ChromaticAberrationPostProcessId;
  68365. /**
  68366. * ID of the grain post process
  68367. */
  68368. private readonly GrainPostProcessId;
  68369. /**
  68370. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68371. */
  68372. sharpen: SharpenPostProcess;
  68373. private _sharpenEffect;
  68374. private bloom;
  68375. /**
  68376. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68377. */
  68378. depthOfField: DepthOfFieldEffect;
  68379. /**
  68380. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68381. */
  68382. fxaa: FxaaPostProcess;
  68383. /**
  68384. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68385. */
  68386. imageProcessing: ImageProcessingPostProcess;
  68387. /**
  68388. * Chromatic aberration post process which will shift rgb colors in the image
  68389. */
  68390. chromaticAberration: ChromaticAberrationPostProcess;
  68391. private _chromaticAberrationEffect;
  68392. /**
  68393. * Grain post process which add noise to the image
  68394. */
  68395. grain: GrainPostProcess;
  68396. private _grainEffect;
  68397. /**
  68398. * Glow post process which adds a glow to emissive areas of the image
  68399. */
  68400. private _glowLayer;
  68401. /**
  68402. * Animations which can be used to tweak settings over a period of time
  68403. */
  68404. animations: Animation[];
  68405. private _imageProcessingConfigurationObserver;
  68406. private _sharpenEnabled;
  68407. private _bloomEnabled;
  68408. private _depthOfFieldEnabled;
  68409. private _depthOfFieldBlurLevel;
  68410. private _fxaaEnabled;
  68411. private _imageProcessingEnabled;
  68412. private _defaultPipelineTextureType;
  68413. private _bloomScale;
  68414. private _chromaticAberrationEnabled;
  68415. private _grainEnabled;
  68416. private _buildAllowed;
  68417. /**
  68418. * Gets active scene
  68419. */
  68420. get scene(): Scene;
  68421. /**
  68422. * Enable or disable the sharpen process from the pipeline
  68423. */
  68424. set sharpenEnabled(enabled: boolean);
  68425. get sharpenEnabled(): boolean;
  68426. private _resizeObserver;
  68427. private _hardwareScaleLevel;
  68428. private _bloomKernel;
  68429. /**
  68430. * Specifies the size of the bloom blur kernel, relative to the final output size
  68431. */
  68432. get bloomKernel(): number;
  68433. set bloomKernel(value: number);
  68434. /**
  68435. * Specifies the weight of the bloom in the final rendering
  68436. */
  68437. private _bloomWeight;
  68438. /**
  68439. * Specifies the luma threshold for the area that will be blurred by the bloom
  68440. */
  68441. private _bloomThreshold;
  68442. private _hdr;
  68443. /**
  68444. * The strength of the bloom.
  68445. */
  68446. set bloomWeight(value: number);
  68447. get bloomWeight(): number;
  68448. /**
  68449. * The strength of the bloom.
  68450. */
  68451. set bloomThreshold(value: number);
  68452. get bloomThreshold(): number;
  68453. /**
  68454. * The scale of the bloom, lower value will provide better performance.
  68455. */
  68456. set bloomScale(value: number);
  68457. get bloomScale(): number;
  68458. /**
  68459. * Enable or disable the bloom from the pipeline
  68460. */
  68461. set bloomEnabled(enabled: boolean);
  68462. get bloomEnabled(): boolean;
  68463. private _rebuildBloom;
  68464. /**
  68465. * If the depth of field is enabled.
  68466. */
  68467. get depthOfFieldEnabled(): boolean;
  68468. set depthOfFieldEnabled(enabled: boolean);
  68469. /**
  68470. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68471. */
  68472. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68473. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68474. /**
  68475. * If the anti aliasing is enabled.
  68476. */
  68477. set fxaaEnabled(enabled: boolean);
  68478. get fxaaEnabled(): boolean;
  68479. private _samples;
  68480. /**
  68481. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68482. */
  68483. set samples(sampleCount: number);
  68484. get samples(): number;
  68485. /**
  68486. * If image processing is enabled.
  68487. */
  68488. set imageProcessingEnabled(enabled: boolean);
  68489. get imageProcessingEnabled(): boolean;
  68490. /**
  68491. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68492. */
  68493. set glowLayerEnabled(enabled: boolean);
  68494. get glowLayerEnabled(): boolean;
  68495. /**
  68496. * Gets the glow layer (or null if not defined)
  68497. */
  68498. get glowLayer(): Nullable<GlowLayer>;
  68499. /**
  68500. * Enable or disable the chromaticAberration process from the pipeline
  68501. */
  68502. set chromaticAberrationEnabled(enabled: boolean);
  68503. get chromaticAberrationEnabled(): boolean;
  68504. /**
  68505. * Enable or disable the grain process from the pipeline
  68506. */
  68507. set grainEnabled(enabled: boolean);
  68508. get grainEnabled(): boolean;
  68509. /**
  68510. * @constructor
  68511. * @param name - The rendering pipeline name (default: "")
  68512. * @param hdr - If high dynamic range textures should be used (default: true)
  68513. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68514. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68515. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68516. */
  68517. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68518. /**
  68519. * Get the class name
  68520. * @returns "DefaultRenderingPipeline"
  68521. */
  68522. getClassName(): string;
  68523. /**
  68524. * Force the compilation of the entire pipeline.
  68525. */
  68526. prepare(): void;
  68527. private _hasCleared;
  68528. private _prevPostProcess;
  68529. private _prevPrevPostProcess;
  68530. private _setAutoClearAndTextureSharing;
  68531. private _depthOfFieldSceneObserver;
  68532. private _buildPipeline;
  68533. private _disposePostProcesses;
  68534. /**
  68535. * Adds a camera to the pipeline
  68536. * @param camera the camera to be added
  68537. */
  68538. addCamera(camera: Camera): void;
  68539. /**
  68540. * Removes a camera from the pipeline
  68541. * @param camera the camera to remove
  68542. */
  68543. removeCamera(camera: Camera): void;
  68544. /**
  68545. * Dispose of the pipeline and stop all post processes
  68546. */
  68547. dispose(): void;
  68548. /**
  68549. * Serialize the rendering pipeline (Used when exporting)
  68550. * @returns the serialized object
  68551. */
  68552. serialize(): any;
  68553. /**
  68554. * Parse the serialized pipeline
  68555. * @param source Source pipeline.
  68556. * @param scene The scene to load the pipeline to.
  68557. * @param rootUrl The URL of the serialized pipeline.
  68558. * @returns An instantiated pipeline from the serialized object.
  68559. */
  68560. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68561. }
  68562. }
  68563. declare module BABYLON {
  68564. /** @hidden */
  68565. export var lensHighlightsPixelShader: {
  68566. name: string;
  68567. shader: string;
  68568. };
  68569. }
  68570. declare module BABYLON {
  68571. /** @hidden */
  68572. export var depthOfFieldPixelShader: {
  68573. name: string;
  68574. shader: string;
  68575. };
  68576. }
  68577. declare module BABYLON {
  68578. /**
  68579. * BABYLON.JS Chromatic Aberration GLSL Shader
  68580. * Author: Olivier Guyot
  68581. * Separates very slightly R, G and B colors on the edges of the screen
  68582. * Inspired by Francois Tarlier & Martins Upitis
  68583. */
  68584. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68585. /**
  68586. * @ignore
  68587. * The chromatic aberration PostProcess id in the pipeline
  68588. */
  68589. LensChromaticAberrationEffect: string;
  68590. /**
  68591. * @ignore
  68592. * The highlights enhancing PostProcess id in the pipeline
  68593. */
  68594. HighlightsEnhancingEffect: string;
  68595. /**
  68596. * @ignore
  68597. * The depth-of-field PostProcess id in the pipeline
  68598. */
  68599. LensDepthOfFieldEffect: string;
  68600. private _scene;
  68601. private _depthTexture;
  68602. private _grainTexture;
  68603. private _chromaticAberrationPostProcess;
  68604. private _highlightsPostProcess;
  68605. private _depthOfFieldPostProcess;
  68606. private _edgeBlur;
  68607. private _grainAmount;
  68608. private _chromaticAberration;
  68609. private _distortion;
  68610. private _highlightsGain;
  68611. private _highlightsThreshold;
  68612. private _dofDistance;
  68613. private _dofAperture;
  68614. private _dofDarken;
  68615. private _dofPentagon;
  68616. private _blurNoise;
  68617. /**
  68618. * @constructor
  68619. *
  68620. * Effect parameters are as follow:
  68621. * {
  68622. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68623. * edge_blur: number; // from 0 to x (1 for realism)
  68624. * distortion: number; // from 0 to x (1 for realism)
  68625. * grain_amount: number; // from 0 to 1
  68626. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68627. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68628. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68629. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68630. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68631. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68632. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68633. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68634. * }
  68635. * Note: if an effect parameter is unset, effect is disabled
  68636. *
  68637. * @param name The rendering pipeline name
  68638. * @param parameters - An object containing all parameters (see above)
  68639. * @param scene The scene linked to this pipeline
  68640. * @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)
  68641. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68642. */
  68643. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68644. /**
  68645. * Get the class name
  68646. * @returns "LensRenderingPipeline"
  68647. */
  68648. getClassName(): string;
  68649. /**
  68650. * Gets associated scene
  68651. */
  68652. get scene(): Scene;
  68653. /**
  68654. * Gets or sets the edge blur
  68655. */
  68656. get edgeBlur(): number;
  68657. set edgeBlur(value: number);
  68658. /**
  68659. * Gets or sets the grain amount
  68660. */
  68661. get grainAmount(): number;
  68662. set grainAmount(value: number);
  68663. /**
  68664. * Gets or sets the chromatic aberration amount
  68665. */
  68666. get chromaticAberration(): number;
  68667. set chromaticAberration(value: number);
  68668. /**
  68669. * Gets or sets the depth of field aperture
  68670. */
  68671. get dofAperture(): number;
  68672. set dofAperture(value: number);
  68673. /**
  68674. * Gets or sets the edge distortion
  68675. */
  68676. get edgeDistortion(): number;
  68677. set edgeDistortion(value: number);
  68678. /**
  68679. * Gets or sets the depth of field distortion
  68680. */
  68681. get dofDistortion(): number;
  68682. set dofDistortion(value: number);
  68683. /**
  68684. * Gets or sets the darken out of focus amount
  68685. */
  68686. get darkenOutOfFocus(): number;
  68687. set darkenOutOfFocus(value: number);
  68688. /**
  68689. * Gets or sets a boolean indicating if blur noise is enabled
  68690. */
  68691. get blurNoise(): boolean;
  68692. set blurNoise(value: boolean);
  68693. /**
  68694. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68695. */
  68696. get pentagonBokeh(): boolean;
  68697. set pentagonBokeh(value: boolean);
  68698. /**
  68699. * Gets or sets the highlight grain amount
  68700. */
  68701. get highlightsGain(): number;
  68702. set highlightsGain(value: number);
  68703. /**
  68704. * Gets or sets the highlight threshold
  68705. */
  68706. get highlightsThreshold(): number;
  68707. set highlightsThreshold(value: number);
  68708. /**
  68709. * Sets the amount of blur at the edges
  68710. * @param amount blur amount
  68711. */
  68712. setEdgeBlur(amount: number): void;
  68713. /**
  68714. * Sets edge blur to 0
  68715. */
  68716. disableEdgeBlur(): void;
  68717. /**
  68718. * Sets the amout of grain
  68719. * @param amount Amount of grain
  68720. */
  68721. setGrainAmount(amount: number): void;
  68722. /**
  68723. * Set grain amount to 0
  68724. */
  68725. disableGrain(): void;
  68726. /**
  68727. * Sets the chromatic aberration amount
  68728. * @param amount amount of chromatic aberration
  68729. */
  68730. setChromaticAberration(amount: number): void;
  68731. /**
  68732. * Sets chromatic aberration amount to 0
  68733. */
  68734. disableChromaticAberration(): void;
  68735. /**
  68736. * Sets the EdgeDistortion amount
  68737. * @param amount amount of EdgeDistortion
  68738. */
  68739. setEdgeDistortion(amount: number): void;
  68740. /**
  68741. * Sets edge distortion to 0
  68742. */
  68743. disableEdgeDistortion(): void;
  68744. /**
  68745. * Sets the FocusDistance amount
  68746. * @param amount amount of FocusDistance
  68747. */
  68748. setFocusDistance(amount: number): void;
  68749. /**
  68750. * Disables depth of field
  68751. */
  68752. disableDepthOfField(): void;
  68753. /**
  68754. * Sets the Aperture amount
  68755. * @param amount amount of Aperture
  68756. */
  68757. setAperture(amount: number): void;
  68758. /**
  68759. * Sets the DarkenOutOfFocus amount
  68760. * @param amount amount of DarkenOutOfFocus
  68761. */
  68762. setDarkenOutOfFocus(amount: number): void;
  68763. private _pentagonBokehIsEnabled;
  68764. /**
  68765. * Creates a pentagon bokeh effect
  68766. */
  68767. enablePentagonBokeh(): void;
  68768. /**
  68769. * Disables the pentagon bokeh effect
  68770. */
  68771. disablePentagonBokeh(): void;
  68772. /**
  68773. * Enables noise blur
  68774. */
  68775. enableNoiseBlur(): void;
  68776. /**
  68777. * Disables noise blur
  68778. */
  68779. disableNoiseBlur(): void;
  68780. /**
  68781. * Sets the HighlightsGain amount
  68782. * @param amount amount of HighlightsGain
  68783. */
  68784. setHighlightsGain(amount: number): void;
  68785. /**
  68786. * Sets the HighlightsThreshold amount
  68787. * @param amount amount of HighlightsThreshold
  68788. */
  68789. setHighlightsThreshold(amount: number): void;
  68790. /**
  68791. * Disables highlights
  68792. */
  68793. disableHighlights(): void;
  68794. /**
  68795. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68796. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68797. */
  68798. dispose(disableDepthRender?: boolean): void;
  68799. private _createChromaticAberrationPostProcess;
  68800. private _createHighlightsPostProcess;
  68801. private _createDepthOfFieldPostProcess;
  68802. private _createGrainTexture;
  68803. }
  68804. }
  68805. declare module BABYLON {
  68806. /** @hidden */
  68807. export var ssao2PixelShader: {
  68808. name: string;
  68809. shader: string;
  68810. };
  68811. }
  68812. declare module BABYLON {
  68813. /** @hidden */
  68814. export var ssaoCombinePixelShader: {
  68815. name: string;
  68816. shader: string;
  68817. };
  68818. }
  68819. declare module BABYLON {
  68820. /**
  68821. * Render pipeline to produce ssao effect
  68822. */
  68823. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  68824. /**
  68825. * @ignore
  68826. * The PassPostProcess id in the pipeline that contains the original scene color
  68827. */
  68828. SSAOOriginalSceneColorEffect: string;
  68829. /**
  68830. * @ignore
  68831. * The SSAO PostProcess id in the pipeline
  68832. */
  68833. SSAORenderEffect: string;
  68834. /**
  68835. * @ignore
  68836. * The horizontal blur PostProcess id in the pipeline
  68837. */
  68838. SSAOBlurHRenderEffect: string;
  68839. /**
  68840. * @ignore
  68841. * The vertical blur PostProcess id in the pipeline
  68842. */
  68843. SSAOBlurVRenderEffect: string;
  68844. /**
  68845. * @ignore
  68846. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68847. */
  68848. SSAOCombineRenderEffect: string;
  68849. /**
  68850. * The output strength of the SSAO post-process. Default value is 1.0.
  68851. */
  68852. totalStrength: number;
  68853. /**
  68854. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  68855. */
  68856. maxZ: number;
  68857. /**
  68858. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  68859. */
  68860. minZAspect: number;
  68861. private _samples;
  68862. /**
  68863. * Number of samples used for the SSAO calculations. Default value is 8
  68864. */
  68865. set samples(n: number);
  68866. get samples(): number;
  68867. private _textureSamples;
  68868. /**
  68869. * Number of samples to use for antialiasing
  68870. */
  68871. set textureSamples(n: number);
  68872. get textureSamples(): number;
  68873. /**
  68874. * Ratio object used for SSAO ratio and blur ratio
  68875. */
  68876. private _ratio;
  68877. /**
  68878. * Dynamically generated sphere sampler.
  68879. */
  68880. private _sampleSphere;
  68881. /**
  68882. * Blur filter offsets
  68883. */
  68884. private _samplerOffsets;
  68885. private _expensiveBlur;
  68886. /**
  68887. * If bilateral blur should be used
  68888. */
  68889. set expensiveBlur(b: boolean);
  68890. get expensiveBlur(): boolean;
  68891. /**
  68892. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  68893. */
  68894. radius: number;
  68895. /**
  68896. * The base color of the SSAO post-process
  68897. * The final result is "base + ssao" between [0, 1]
  68898. */
  68899. base: number;
  68900. /**
  68901. * Support test.
  68902. */
  68903. static get IsSupported(): boolean;
  68904. private _scene;
  68905. private _depthTexture;
  68906. private _normalTexture;
  68907. private _randomTexture;
  68908. private _originalColorPostProcess;
  68909. private _ssaoPostProcess;
  68910. private _blurHPostProcess;
  68911. private _blurVPostProcess;
  68912. private _ssaoCombinePostProcess;
  68913. /**
  68914. * Gets active scene
  68915. */
  68916. get scene(): Scene;
  68917. /**
  68918. * @constructor
  68919. * @param name The rendering pipeline name
  68920. * @param scene The scene linked to this pipeline
  68921. * @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 }
  68922. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68923. */
  68924. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68925. /**
  68926. * Get the class name
  68927. * @returns "SSAO2RenderingPipeline"
  68928. */
  68929. getClassName(): string;
  68930. /**
  68931. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68932. */
  68933. dispose(disableGeometryBufferRenderer?: boolean): void;
  68934. private _createBlurPostProcess;
  68935. /** @hidden */
  68936. _rebuild(): void;
  68937. private _bits;
  68938. private _radicalInverse_VdC;
  68939. private _hammersley;
  68940. private _hemisphereSample_uniform;
  68941. private _generateHemisphere;
  68942. private _createSSAOPostProcess;
  68943. private _createSSAOCombinePostProcess;
  68944. private _createRandomTexture;
  68945. /**
  68946. * Serialize the rendering pipeline (Used when exporting)
  68947. * @returns the serialized object
  68948. */
  68949. serialize(): any;
  68950. /**
  68951. * Parse the serialized pipeline
  68952. * @param source Source pipeline.
  68953. * @param scene The scene to load the pipeline to.
  68954. * @param rootUrl The URL of the serialized pipeline.
  68955. * @returns An instantiated pipeline from the serialized object.
  68956. */
  68957. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  68958. }
  68959. }
  68960. declare module BABYLON {
  68961. /** @hidden */
  68962. export var ssaoPixelShader: {
  68963. name: string;
  68964. shader: string;
  68965. };
  68966. }
  68967. declare module BABYLON {
  68968. /**
  68969. * Render pipeline to produce ssao effect
  68970. */
  68971. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  68972. /**
  68973. * @ignore
  68974. * The PassPostProcess id in the pipeline that contains the original scene color
  68975. */
  68976. SSAOOriginalSceneColorEffect: string;
  68977. /**
  68978. * @ignore
  68979. * The SSAO PostProcess id in the pipeline
  68980. */
  68981. SSAORenderEffect: string;
  68982. /**
  68983. * @ignore
  68984. * The horizontal blur PostProcess id in the pipeline
  68985. */
  68986. SSAOBlurHRenderEffect: string;
  68987. /**
  68988. * @ignore
  68989. * The vertical blur PostProcess id in the pipeline
  68990. */
  68991. SSAOBlurVRenderEffect: string;
  68992. /**
  68993. * @ignore
  68994. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68995. */
  68996. SSAOCombineRenderEffect: string;
  68997. /**
  68998. * The output strength of the SSAO post-process. Default value is 1.0.
  68999. */
  69000. totalStrength: number;
  69001. /**
  69002. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69003. */
  69004. radius: number;
  69005. /**
  69006. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69007. * Must not be equal to fallOff and superior to fallOff.
  69008. * Default value is 0.0075
  69009. */
  69010. area: number;
  69011. /**
  69012. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69013. * Must not be equal to area and inferior to area.
  69014. * Default value is 0.000001
  69015. */
  69016. fallOff: number;
  69017. /**
  69018. * The base color of the SSAO post-process
  69019. * The final result is "base + ssao" between [0, 1]
  69020. */
  69021. base: number;
  69022. private _scene;
  69023. private _depthTexture;
  69024. private _randomTexture;
  69025. private _originalColorPostProcess;
  69026. private _ssaoPostProcess;
  69027. private _blurHPostProcess;
  69028. private _blurVPostProcess;
  69029. private _ssaoCombinePostProcess;
  69030. private _firstUpdate;
  69031. /**
  69032. * Gets active scene
  69033. */
  69034. get scene(): Scene;
  69035. /**
  69036. * @constructor
  69037. * @param name - The rendering pipeline name
  69038. * @param scene - The scene linked to this pipeline
  69039. * @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 }
  69040. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69041. */
  69042. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69043. /**
  69044. * Get the class name
  69045. * @returns "SSAORenderingPipeline"
  69046. */
  69047. getClassName(): string;
  69048. /**
  69049. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69050. */
  69051. dispose(disableDepthRender?: boolean): void;
  69052. private _createBlurPostProcess;
  69053. /** @hidden */
  69054. _rebuild(): void;
  69055. private _createSSAOPostProcess;
  69056. private _createSSAOCombinePostProcess;
  69057. private _createRandomTexture;
  69058. }
  69059. }
  69060. declare module BABYLON {
  69061. /** @hidden */
  69062. export var screenSpaceReflectionPixelShader: {
  69063. name: string;
  69064. shader: string;
  69065. };
  69066. }
  69067. declare module BABYLON {
  69068. /**
  69069. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69070. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69071. */
  69072. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69073. /**
  69074. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69075. */
  69076. threshold: number;
  69077. /**
  69078. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69079. */
  69080. strength: number;
  69081. /**
  69082. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69083. */
  69084. reflectionSpecularFalloffExponent: number;
  69085. /**
  69086. * 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]
  69087. */
  69088. step: number;
  69089. /**
  69090. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69091. */
  69092. roughnessFactor: number;
  69093. private _geometryBufferRenderer;
  69094. private _enableSmoothReflections;
  69095. private _reflectionSamples;
  69096. private _smoothSteps;
  69097. /**
  69098. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69099. * @param name The name of the effect.
  69100. * @param scene The scene containing the objects to calculate reflections.
  69101. * @param options The required width/height ratio to downsize to before computing the render pass.
  69102. * @param camera The camera to apply the render pass to.
  69103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69104. * @param engine The engine which the post process will be applied. (default: current engine)
  69105. * @param reusable If the post process can be reused on the same frame. (default: false)
  69106. * @param textureType Type of textures used when performing the post process. (default: 0)
  69107. * @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)
  69108. */
  69109. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69110. /**
  69111. * Gets wether or not smoothing reflections is enabled.
  69112. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69113. */
  69114. get enableSmoothReflections(): boolean;
  69115. /**
  69116. * Sets wether or not smoothing reflections is enabled.
  69117. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69118. */
  69119. set enableSmoothReflections(enabled: boolean);
  69120. /**
  69121. * Gets the number of samples taken while computing reflections. More samples count is high,
  69122. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69123. */
  69124. get reflectionSamples(): number;
  69125. /**
  69126. * Sets the number of samples taken while computing reflections. More samples count is high,
  69127. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69128. */
  69129. set reflectionSamples(samples: number);
  69130. /**
  69131. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69132. * more the post-process will require GPU power and can generate a drop in FPS.
  69133. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69134. */
  69135. get smoothSteps(): number;
  69136. set smoothSteps(steps: number);
  69137. private _updateEffectDefines;
  69138. }
  69139. }
  69140. declare module BABYLON {
  69141. /** @hidden */
  69142. export var standardPixelShader: {
  69143. name: string;
  69144. shader: string;
  69145. };
  69146. }
  69147. declare module BABYLON {
  69148. /**
  69149. * Standard rendering pipeline
  69150. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69151. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69152. */
  69153. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69154. /**
  69155. * Public members
  69156. */
  69157. /**
  69158. * Post-process which contains the original scene color before the pipeline applies all the effects
  69159. */
  69160. originalPostProcess: Nullable<PostProcess>;
  69161. /**
  69162. * Post-process used to down scale an image x4
  69163. */
  69164. downSampleX4PostProcess: Nullable<PostProcess>;
  69165. /**
  69166. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69167. */
  69168. brightPassPostProcess: Nullable<PostProcess>;
  69169. /**
  69170. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69171. */
  69172. blurHPostProcesses: PostProcess[];
  69173. /**
  69174. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69175. */
  69176. blurVPostProcesses: PostProcess[];
  69177. /**
  69178. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69179. */
  69180. textureAdderPostProcess: Nullable<PostProcess>;
  69181. /**
  69182. * Post-process used to create volumetric lighting effect
  69183. */
  69184. volumetricLightPostProcess: Nullable<PostProcess>;
  69185. /**
  69186. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69187. */
  69188. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69189. /**
  69190. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69191. */
  69192. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69193. /**
  69194. * Post-process used to merge the volumetric light effect and the real scene color
  69195. */
  69196. volumetricLightMergePostProces: Nullable<PostProcess>;
  69197. /**
  69198. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69199. */
  69200. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69201. /**
  69202. * Base post-process used to calculate the average luminance of the final image for HDR
  69203. */
  69204. luminancePostProcess: Nullable<PostProcess>;
  69205. /**
  69206. * Post-processes used to create down sample post-processes in order to get
  69207. * the average luminance of the final image for HDR
  69208. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69209. */
  69210. luminanceDownSamplePostProcesses: PostProcess[];
  69211. /**
  69212. * Post-process used to create a HDR effect (light adaptation)
  69213. */
  69214. hdrPostProcess: Nullable<PostProcess>;
  69215. /**
  69216. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69217. */
  69218. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69219. /**
  69220. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69221. */
  69222. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69223. /**
  69224. * Post-process used to merge the final HDR post-process and the real scene color
  69225. */
  69226. hdrFinalPostProcess: Nullable<PostProcess>;
  69227. /**
  69228. * Post-process used to create a lens flare effect
  69229. */
  69230. lensFlarePostProcess: Nullable<PostProcess>;
  69231. /**
  69232. * Post-process that merges the result of the lens flare post-process and the real scene color
  69233. */
  69234. lensFlareComposePostProcess: Nullable<PostProcess>;
  69235. /**
  69236. * Post-process used to create a motion blur effect
  69237. */
  69238. motionBlurPostProcess: Nullable<PostProcess>;
  69239. /**
  69240. * Post-process used to create a depth of field effect
  69241. */
  69242. depthOfFieldPostProcess: Nullable<PostProcess>;
  69243. /**
  69244. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69245. */
  69246. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69247. /**
  69248. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69249. */
  69250. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69251. /**
  69252. * Represents the brightness threshold in order to configure the illuminated surfaces
  69253. */
  69254. brightThreshold: number;
  69255. /**
  69256. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69257. */
  69258. blurWidth: number;
  69259. /**
  69260. * Sets if the blur for highlighted surfaces must be only horizontal
  69261. */
  69262. horizontalBlur: boolean;
  69263. /**
  69264. * Gets the overall exposure used by the pipeline
  69265. */
  69266. get exposure(): number;
  69267. /**
  69268. * Sets the overall exposure used by the pipeline
  69269. */
  69270. set exposure(value: number);
  69271. /**
  69272. * Texture used typically to simulate "dirty" on camera lens
  69273. */
  69274. lensTexture: Nullable<Texture>;
  69275. /**
  69276. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69277. */
  69278. volumetricLightCoefficient: number;
  69279. /**
  69280. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69281. */
  69282. volumetricLightPower: number;
  69283. /**
  69284. * Used the set the blur intensity to smooth the volumetric lights
  69285. */
  69286. volumetricLightBlurScale: number;
  69287. /**
  69288. * Light (spot or directional) used to generate the volumetric lights rays
  69289. * The source light must have a shadow generate so the pipeline can get its
  69290. * depth map
  69291. */
  69292. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69293. /**
  69294. * For eye adaptation, represents the minimum luminance the eye can see
  69295. */
  69296. hdrMinimumLuminance: number;
  69297. /**
  69298. * For eye adaptation, represents the decrease luminance speed
  69299. */
  69300. hdrDecreaseRate: number;
  69301. /**
  69302. * For eye adaptation, represents the increase luminance speed
  69303. */
  69304. hdrIncreaseRate: number;
  69305. /**
  69306. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69307. */
  69308. get hdrAutoExposure(): boolean;
  69309. /**
  69310. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69311. */
  69312. set hdrAutoExposure(value: boolean);
  69313. /**
  69314. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69315. */
  69316. lensColorTexture: Nullable<Texture>;
  69317. /**
  69318. * The overall strengh for the lens flare effect
  69319. */
  69320. lensFlareStrength: number;
  69321. /**
  69322. * Dispersion coefficient for lens flare ghosts
  69323. */
  69324. lensFlareGhostDispersal: number;
  69325. /**
  69326. * Main lens flare halo width
  69327. */
  69328. lensFlareHaloWidth: number;
  69329. /**
  69330. * Based on the lens distortion effect, defines how much the lens flare result
  69331. * is distorted
  69332. */
  69333. lensFlareDistortionStrength: number;
  69334. /**
  69335. * Configures the blur intensity used for for lens flare (halo)
  69336. */
  69337. lensFlareBlurWidth: number;
  69338. /**
  69339. * Lens star texture must be used to simulate rays on the flares and is available
  69340. * in the documentation
  69341. */
  69342. lensStarTexture: Nullable<Texture>;
  69343. /**
  69344. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69345. * flare effect by taking account of the dirt texture
  69346. */
  69347. lensFlareDirtTexture: Nullable<Texture>;
  69348. /**
  69349. * Represents the focal length for the depth of field effect
  69350. */
  69351. depthOfFieldDistance: number;
  69352. /**
  69353. * Represents the blur intensity for the blurred part of the depth of field effect
  69354. */
  69355. depthOfFieldBlurWidth: number;
  69356. /**
  69357. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69358. */
  69359. get motionStrength(): number;
  69360. /**
  69361. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69362. */
  69363. set motionStrength(strength: number);
  69364. /**
  69365. * Gets wether or not the motion blur post-process is object based or screen based.
  69366. */
  69367. get objectBasedMotionBlur(): boolean;
  69368. /**
  69369. * Sets wether or not the motion blur post-process should be object based or screen based
  69370. */
  69371. set objectBasedMotionBlur(value: boolean);
  69372. /**
  69373. * List of animations for the pipeline (IAnimatable implementation)
  69374. */
  69375. animations: Animation[];
  69376. /**
  69377. * Private members
  69378. */
  69379. private _scene;
  69380. private _currentDepthOfFieldSource;
  69381. private _basePostProcess;
  69382. private _fixedExposure;
  69383. private _currentExposure;
  69384. private _hdrAutoExposure;
  69385. private _hdrCurrentLuminance;
  69386. private _motionStrength;
  69387. private _isObjectBasedMotionBlur;
  69388. private _floatTextureType;
  69389. private _camerasToBeAttached;
  69390. private _ratio;
  69391. private _bloomEnabled;
  69392. private _depthOfFieldEnabled;
  69393. private _vlsEnabled;
  69394. private _lensFlareEnabled;
  69395. private _hdrEnabled;
  69396. private _motionBlurEnabled;
  69397. private _fxaaEnabled;
  69398. private _screenSpaceReflectionsEnabled;
  69399. private _motionBlurSamples;
  69400. private _volumetricLightStepsCount;
  69401. private _samples;
  69402. /**
  69403. * @ignore
  69404. * Specifies if the bloom pipeline is enabled
  69405. */
  69406. get BloomEnabled(): boolean;
  69407. set BloomEnabled(enabled: boolean);
  69408. /**
  69409. * @ignore
  69410. * Specifies if the depth of field pipeline is enabed
  69411. */
  69412. get DepthOfFieldEnabled(): boolean;
  69413. set DepthOfFieldEnabled(enabled: boolean);
  69414. /**
  69415. * @ignore
  69416. * Specifies if the lens flare pipeline is enabed
  69417. */
  69418. get LensFlareEnabled(): boolean;
  69419. set LensFlareEnabled(enabled: boolean);
  69420. /**
  69421. * @ignore
  69422. * Specifies if the HDR pipeline is enabled
  69423. */
  69424. get HDREnabled(): boolean;
  69425. set HDREnabled(enabled: boolean);
  69426. /**
  69427. * @ignore
  69428. * Specifies if the volumetric lights scattering effect is enabled
  69429. */
  69430. get VLSEnabled(): boolean;
  69431. set VLSEnabled(enabled: boolean);
  69432. /**
  69433. * @ignore
  69434. * Specifies if the motion blur effect is enabled
  69435. */
  69436. get MotionBlurEnabled(): boolean;
  69437. set MotionBlurEnabled(enabled: boolean);
  69438. /**
  69439. * Specifies if anti-aliasing is enabled
  69440. */
  69441. get fxaaEnabled(): boolean;
  69442. set fxaaEnabled(enabled: boolean);
  69443. /**
  69444. * Specifies if screen space reflections are enabled.
  69445. */
  69446. get screenSpaceReflectionsEnabled(): boolean;
  69447. set screenSpaceReflectionsEnabled(enabled: boolean);
  69448. /**
  69449. * Specifies the number of steps used to calculate the volumetric lights
  69450. * Typically in interval [50, 200]
  69451. */
  69452. get volumetricLightStepsCount(): number;
  69453. set volumetricLightStepsCount(count: number);
  69454. /**
  69455. * Specifies the number of samples used for the motion blur effect
  69456. * Typically in interval [16, 64]
  69457. */
  69458. get motionBlurSamples(): number;
  69459. set motionBlurSamples(samples: number);
  69460. /**
  69461. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69462. */
  69463. get samples(): number;
  69464. set samples(sampleCount: number);
  69465. /**
  69466. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69467. * @constructor
  69468. * @param name The rendering pipeline name
  69469. * @param scene The scene linked to this pipeline
  69470. * @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)
  69471. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69472. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69473. */
  69474. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69475. private _buildPipeline;
  69476. private _createDownSampleX4PostProcess;
  69477. private _createBrightPassPostProcess;
  69478. private _createBlurPostProcesses;
  69479. private _createTextureAdderPostProcess;
  69480. private _createVolumetricLightPostProcess;
  69481. private _createLuminancePostProcesses;
  69482. private _createHdrPostProcess;
  69483. private _createLensFlarePostProcess;
  69484. private _createDepthOfFieldPostProcess;
  69485. private _createMotionBlurPostProcess;
  69486. private _getDepthTexture;
  69487. private _disposePostProcesses;
  69488. /**
  69489. * Dispose of the pipeline and stop all post processes
  69490. */
  69491. dispose(): void;
  69492. /**
  69493. * Serialize the rendering pipeline (Used when exporting)
  69494. * @returns the serialized object
  69495. */
  69496. serialize(): any;
  69497. /**
  69498. * Parse the serialized pipeline
  69499. * @param source Source pipeline.
  69500. * @param scene The scene to load the pipeline to.
  69501. * @param rootUrl The URL of the serialized pipeline.
  69502. * @returns An instantiated pipeline from the serialized object.
  69503. */
  69504. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69505. /**
  69506. * Luminance steps
  69507. */
  69508. static LuminanceSteps: number;
  69509. }
  69510. }
  69511. declare module BABYLON {
  69512. /** @hidden */
  69513. export var stereoscopicInterlacePixelShader: {
  69514. name: string;
  69515. shader: string;
  69516. };
  69517. }
  69518. declare module BABYLON {
  69519. /**
  69520. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  69521. */
  69522. export class StereoscopicInterlacePostProcessI extends PostProcess {
  69523. private _stepSize;
  69524. private _passedProcess;
  69525. /**
  69526. * Initializes a StereoscopicInterlacePostProcessI
  69527. * @param name The name of the effect.
  69528. * @param rigCameras The rig cameras to be appled to the post process
  69529. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  69530. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  69531. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69532. * @param engine The engine which the post process will be applied. (default: current engine)
  69533. * @param reusable If the post process can be reused on the same frame. (default: false)
  69534. */
  69535. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69536. }
  69537. /**
  69538. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  69539. */
  69540. export class StereoscopicInterlacePostProcess extends PostProcess {
  69541. private _stepSize;
  69542. private _passedProcess;
  69543. /**
  69544. * Initializes a StereoscopicInterlacePostProcess
  69545. * @param name The name of the effect.
  69546. * @param rigCameras The rig cameras to be appled to the post process
  69547. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  69548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69549. * @param engine The engine which the post process will be applied. (default: current engine)
  69550. * @param reusable If the post process can be reused on the same frame. (default: false)
  69551. */
  69552. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69553. }
  69554. }
  69555. declare module BABYLON {
  69556. /** @hidden */
  69557. export var tonemapPixelShader: {
  69558. name: string;
  69559. shader: string;
  69560. };
  69561. }
  69562. declare module BABYLON {
  69563. /** Defines operator used for tonemapping */
  69564. export enum TonemappingOperator {
  69565. /** Hable */
  69566. Hable = 0,
  69567. /** Reinhard */
  69568. Reinhard = 1,
  69569. /** HejiDawson */
  69570. HejiDawson = 2,
  69571. /** Photographic */
  69572. Photographic = 3
  69573. }
  69574. /**
  69575. * Defines a post process to apply tone mapping
  69576. */
  69577. export class TonemapPostProcess extends PostProcess {
  69578. private _operator;
  69579. /** Defines the required exposure adjustement */
  69580. exposureAdjustment: number;
  69581. /**
  69582. * Creates a new TonemapPostProcess
  69583. * @param name defines the name of the postprocess
  69584. * @param _operator defines the operator to use
  69585. * @param exposureAdjustment defines the required exposure adjustement
  69586. * @param camera defines the camera to use (can be null)
  69587. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69588. * @param engine defines the hosting engine (can be ignore if camera is set)
  69589. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69590. */
  69591. constructor(name: string, _operator: TonemappingOperator,
  69592. /** Defines the required exposure adjustement */
  69593. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69594. }
  69595. }
  69596. declare module BABYLON {
  69597. /** @hidden */
  69598. export var volumetricLightScatteringPixelShader: {
  69599. name: string;
  69600. shader: string;
  69601. };
  69602. }
  69603. declare module BABYLON {
  69604. /** @hidden */
  69605. export var volumetricLightScatteringPassVertexShader: {
  69606. name: string;
  69607. shader: string;
  69608. };
  69609. }
  69610. declare module BABYLON {
  69611. /** @hidden */
  69612. export var volumetricLightScatteringPassPixelShader: {
  69613. name: string;
  69614. shader: string;
  69615. };
  69616. }
  69617. declare module BABYLON {
  69618. /**
  69619. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69620. */
  69621. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69622. private _volumetricLightScatteringPass;
  69623. private _volumetricLightScatteringRTT;
  69624. private _viewPort;
  69625. private _screenCoordinates;
  69626. private _cachedDefines;
  69627. /**
  69628. * If not undefined, the mesh position is computed from the attached node position
  69629. */
  69630. attachedNode: {
  69631. position: Vector3;
  69632. };
  69633. /**
  69634. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69635. */
  69636. customMeshPosition: Vector3;
  69637. /**
  69638. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69639. */
  69640. useCustomMeshPosition: boolean;
  69641. /**
  69642. * If the post-process should inverse the light scattering direction
  69643. */
  69644. invert: boolean;
  69645. /**
  69646. * The internal mesh used by the post-process
  69647. */
  69648. mesh: Mesh;
  69649. /**
  69650. * @hidden
  69651. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69652. */
  69653. get useDiffuseColor(): boolean;
  69654. set useDiffuseColor(useDiffuseColor: boolean);
  69655. /**
  69656. * Array containing the excluded meshes not rendered in the internal pass
  69657. */
  69658. excludedMeshes: AbstractMesh[];
  69659. /**
  69660. * Controls the overall intensity of the post-process
  69661. */
  69662. exposure: number;
  69663. /**
  69664. * Dissipates each sample's contribution in range [0, 1]
  69665. */
  69666. decay: number;
  69667. /**
  69668. * Controls the overall intensity of each sample
  69669. */
  69670. weight: number;
  69671. /**
  69672. * Controls the density of each sample
  69673. */
  69674. density: number;
  69675. /**
  69676. * @constructor
  69677. * @param name The post-process name
  69678. * @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)
  69679. * @param camera The camera that the post-process will be attached to
  69680. * @param mesh The mesh used to create the light scattering
  69681. * @param samples The post-process quality, default 100
  69682. * @param samplingModeThe post-process filtering mode
  69683. * @param engine The babylon engine
  69684. * @param reusable If the post-process is reusable
  69685. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69686. */
  69687. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69688. /**
  69689. * Returns the string "VolumetricLightScatteringPostProcess"
  69690. * @returns "VolumetricLightScatteringPostProcess"
  69691. */
  69692. getClassName(): string;
  69693. private _isReady;
  69694. /**
  69695. * Sets the new light position for light scattering effect
  69696. * @param position The new custom light position
  69697. */
  69698. setCustomMeshPosition(position: Vector3): void;
  69699. /**
  69700. * Returns the light position for light scattering effect
  69701. * @return Vector3 The custom light position
  69702. */
  69703. getCustomMeshPosition(): Vector3;
  69704. /**
  69705. * Disposes the internal assets and detaches the post-process from the camera
  69706. */
  69707. dispose(camera: Camera): void;
  69708. /**
  69709. * Returns the render target texture used by the post-process
  69710. * @return the render target texture used by the post-process
  69711. */
  69712. getPass(): RenderTargetTexture;
  69713. private _meshExcluded;
  69714. private _createPass;
  69715. private _updateMeshScreenCoordinates;
  69716. /**
  69717. * Creates a default mesh for the Volumeric Light Scattering post-process
  69718. * @param name The mesh name
  69719. * @param scene The scene where to create the mesh
  69720. * @return the default mesh
  69721. */
  69722. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69723. }
  69724. }
  69725. declare module BABYLON {
  69726. interface Scene {
  69727. /** @hidden (Backing field) */
  69728. _boundingBoxRenderer: BoundingBoxRenderer;
  69729. /** @hidden (Backing field) */
  69730. _forceShowBoundingBoxes: boolean;
  69731. /**
  69732. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69733. */
  69734. forceShowBoundingBoxes: boolean;
  69735. /**
  69736. * Gets the bounding box renderer associated with the scene
  69737. * @returns a BoundingBoxRenderer
  69738. */
  69739. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69740. }
  69741. interface AbstractMesh {
  69742. /** @hidden (Backing field) */
  69743. _showBoundingBox: boolean;
  69744. /**
  69745. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69746. */
  69747. showBoundingBox: boolean;
  69748. }
  69749. /**
  69750. * Component responsible of rendering the bounding box of the meshes in a scene.
  69751. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69752. */
  69753. export class BoundingBoxRenderer implements ISceneComponent {
  69754. /**
  69755. * The component name helpfull to identify the component in the list of scene components.
  69756. */
  69757. readonly name: string;
  69758. /**
  69759. * The scene the component belongs to.
  69760. */
  69761. scene: Scene;
  69762. /**
  69763. * Color of the bounding box lines placed in front of an object
  69764. */
  69765. frontColor: Color3;
  69766. /**
  69767. * Color of the bounding box lines placed behind an object
  69768. */
  69769. backColor: Color3;
  69770. /**
  69771. * Defines if the renderer should show the back lines or not
  69772. */
  69773. showBackLines: boolean;
  69774. /**
  69775. * Observable raised before rendering a bounding box
  69776. */
  69777. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  69778. /**
  69779. * Observable raised after rendering a bounding box
  69780. */
  69781. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  69782. /**
  69783. * @hidden
  69784. */
  69785. renderList: SmartArray<BoundingBox>;
  69786. private _colorShader;
  69787. private _vertexBuffers;
  69788. private _indexBuffer;
  69789. private _fillIndexBuffer;
  69790. private _fillIndexData;
  69791. /**
  69792. * Instantiates a new bounding box renderer in a scene.
  69793. * @param scene the scene the renderer renders in
  69794. */
  69795. constructor(scene: Scene);
  69796. /**
  69797. * Registers the component in a given scene
  69798. */
  69799. register(): void;
  69800. private _evaluateSubMesh;
  69801. private _activeMesh;
  69802. private _prepareRessources;
  69803. private _createIndexBuffer;
  69804. /**
  69805. * Rebuilds the elements related to this component in case of
  69806. * context lost for instance.
  69807. */
  69808. rebuild(): void;
  69809. /**
  69810. * @hidden
  69811. */
  69812. reset(): void;
  69813. /**
  69814. * Render the bounding boxes of a specific rendering group
  69815. * @param renderingGroupId defines the rendering group to render
  69816. */
  69817. render(renderingGroupId: number): void;
  69818. /**
  69819. * In case of occlusion queries, we can render the occlusion bounding box through this method
  69820. * @param mesh Define the mesh to render the occlusion bounding box for
  69821. */
  69822. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  69823. /**
  69824. * Dispose and release the resources attached to this renderer.
  69825. */
  69826. dispose(): void;
  69827. }
  69828. }
  69829. declare module BABYLON {
  69830. interface Scene {
  69831. /** @hidden (Backing field) */
  69832. _depthRenderer: {
  69833. [id: string]: DepthRenderer;
  69834. };
  69835. /**
  69836. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  69837. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  69838. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  69839. * @returns the created depth renderer
  69840. */
  69841. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  69842. /**
  69843. * Disables a depth renderer for a given camera
  69844. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  69845. */
  69846. disableDepthRenderer(camera?: Nullable<Camera>): void;
  69847. }
  69848. /**
  69849. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  69850. * in several rendering techniques.
  69851. */
  69852. export class DepthRendererSceneComponent implements ISceneComponent {
  69853. /**
  69854. * The component name helpfull to identify the component in the list of scene components.
  69855. */
  69856. readonly name: string;
  69857. /**
  69858. * The scene the component belongs to.
  69859. */
  69860. scene: Scene;
  69861. /**
  69862. * Creates a new instance of the component for the given scene
  69863. * @param scene Defines the scene to register the component in
  69864. */
  69865. constructor(scene: Scene);
  69866. /**
  69867. * Registers the component in a given scene
  69868. */
  69869. register(): void;
  69870. /**
  69871. * Rebuilds the elements related to this component in case of
  69872. * context lost for instance.
  69873. */
  69874. rebuild(): void;
  69875. /**
  69876. * Disposes the component and the associated ressources
  69877. */
  69878. dispose(): void;
  69879. private _gatherRenderTargets;
  69880. private _gatherActiveCameraRenderTargets;
  69881. }
  69882. }
  69883. declare module BABYLON {
  69884. /** @hidden */
  69885. export var outlinePixelShader: {
  69886. name: string;
  69887. shader: string;
  69888. };
  69889. }
  69890. declare module BABYLON {
  69891. /** @hidden */
  69892. export var outlineVertexShader: {
  69893. name: string;
  69894. shader: string;
  69895. };
  69896. }
  69897. declare module BABYLON {
  69898. interface Scene {
  69899. /** @hidden */
  69900. _outlineRenderer: OutlineRenderer;
  69901. /**
  69902. * Gets the outline renderer associated with the scene
  69903. * @returns a OutlineRenderer
  69904. */
  69905. getOutlineRenderer(): OutlineRenderer;
  69906. }
  69907. interface AbstractMesh {
  69908. /** @hidden (Backing field) */
  69909. _renderOutline: boolean;
  69910. /**
  69911. * Gets or sets a boolean indicating if the outline must be rendered as well
  69912. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  69913. */
  69914. renderOutline: boolean;
  69915. /** @hidden (Backing field) */
  69916. _renderOverlay: boolean;
  69917. /**
  69918. * Gets or sets a boolean indicating if the overlay must be rendered as well
  69919. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  69920. */
  69921. renderOverlay: boolean;
  69922. }
  69923. /**
  69924. * This class is responsible to draw bothe outline/overlay of meshes.
  69925. * It should not be used directly but through the available method on mesh.
  69926. */
  69927. export class OutlineRenderer implements ISceneComponent {
  69928. /**
  69929. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  69930. */
  69931. private static _StencilReference;
  69932. /**
  69933. * The name of the component. Each component must have a unique name.
  69934. */
  69935. name: string;
  69936. /**
  69937. * The scene the component belongs to.
  69938. */
  69939. scene: Scene;
  69940. /**
  69941. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  69942. */
  69943. zOffset: number;
  69944. private _engine;
  69945. private _effect;
  69946. private _cachedDefines;
  69947. private _savedDepthWrite;
  69948. /**
  69949. * Instantiates a new outline renderer. (There could be only one per scene).
  69950. * @param scene Defines the scene it belongs to
  69951. */
  69952. constructor(scene: Scene);
  69953. /**
  69954. * Register the component to one instance of a scene.
  69955. */
  69956. register(): void;
  69957. /**
  69958. * Rebuilds the elements related to this component in case of
  69959. * context lost for instance.
  69960. */
  69961. rebuild(): void;
  69962. /**
  69963. * Disposes the component and the associated ressources.
  69964. */
  69965. dispose(): void;
  69966. /**
  69967. * Renders the outline in the canvas.
  69968. * @param subMesh Defines the sumesh to render
  69969. * @param batch Defines the batch of meshes in case of instances
  69970. * @param useOverlay Defines if the rendering is for the overlay or the outline
  69971. */
  69972. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  69973. /**
  69974. * Returns whether or not the outline renderer is ready for a given submesh.
  69975. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  69976. * @param subMesh Defines the submesh to check readyness for
  69977. * @param useInstances Defines wheter wee are trying to render instances or not
  69978. * @returns true if ready otherwise false
  69979. */
  69980. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69981. private _beforeRenderingMesh;
  69982. private _afterRenderingMesh;
  69983. }
  69984. }
  69985. declare module BABYLON {
  69986. /**
  69987. * Defines the basic options interface of a Sprite Frame Source Size.
  69988. */
  69989. export interface ISpriteJSONSpriteSourceSize {
  69990. /**
  69991. * number of the original width of the Frame
  69992. */
  69993. w: number;
  69994. /**
  69995. * number of the original height of the Frame
  69996. */
  69997. h: number;
  69998. }
  69999. /**
  70000. * Defines the basic options interface of a Sprite Frame Data.
  70001. */
  70002. export interface ISpriteJSONSpriteFrameData {
  70003. /**
  70004. * number of the x offset of the Frame
  70005. */
  70006. x: number;
  70007. /**
  70008. * number of the y offset of the Frame
  70009. */
  70010. y: number;
  70011. /**
  70012. * number of the width of the Frame
  70013. */
  70014. w: number;
  70015. /**
  70016. * number of the height of the Frame
  70017. */
  70018. h: number;
  70019. }
  70020. /**
  70021. * Defines the basic options interface of a JSON Sprite.
  70022. */
  70023. export interface ISpriteJSONSprite {
  70024. /**
  70025. * string name of the Frame
  70026. */
  70027. filename: string;
  70028. /**
  70029. * ISpriteJSONSpriteFrame basic object of the frame data
  70030. */
  70031. frame: ISpriteJSONSpriteFrameData;
  70032. /**
  70033. * boolean to flag is the frame was rotated.
  70034. */
  70035. rotated: boolean;
  70036. /**
  70037. * boolean to flag is the frame was trimmed.
  70038. */
  70039. trimmed: boolean;
  70040. /**
  70041. * ISpriteJSONSpriteFrame basic object of the source data
  70042. */
  70043. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70044. /**
  70045. * ISpriteJSONSpriteFrame basic object of the source data
  70046. */
  70047. sourceSize: ISpriteJSONSpriteSourceSize;
  70048. }
  70049. /**
  70050. * Defines the basic options interface of a JSON atlas.
  70051. */
  70052. export interface ISpriteJSONAtlas {
  70053. /**
  70054. * Array of objects that contain the frame data.
  70055. */
  70056. frames: Array<ISpriteJSONSprite>;
  70057. /**
  70058. * object basic object containing the sprite meta data.
  70059. */
  70060. meta?: object;
  70061. }
  70062. }
  70063. declare module BABYLON {
  70064. /** @hidden */
  70065. export var spriteMapPixelShader: {
  70066. name: string;
  70067. shader: string;
  70068. };
  70069. }
  70070. declare module BABYLON {
  70071. /** @hidden */
  70072. export var spriteMapVertexShader: {
  70073. name: string;
  70074. shader: string;
  70075. };
  70076. }
  70077. declare module BABYLON {
  70078. /**
  70079. * Defines the basic options interface of a SpriteMap
  70080. */
  70081. export interface ISpriteMapOptions {
  70082. /**
  70083. * Vector2 of the number of cells in the grid.
  70084. */
  70085. stageSize?: Vector2;
  70086. /**
  70087. * Vector2 of the size of the output plane in World Units.
  70088. */
  70089. outputSize?: Vector2;
  70090. /**
  70091. * Vector3 of the position of the output plane in World Units.
  70092. */
  70093. outputPosition?: Vector3;
  70094. /**
  70095. * Vector3 of the rotation of the output plane.
  70096. */
  70097. outputRotation?: Vector3;
  70098. /**
  70099. * number of layers that the system will reserve in resources.
  70100. */
  70101. layerCount?: number;
  70102. /**
  70103. * number of max animation frames a single cell will reserve in resources.
  70104. */
  70105. maxAnimationFrames?: number;
  70106. /**
  70107. * number cell index of the base tile when the system compiles.
  70108. */
  70109. baseTile?: number;
  70110. /**
  70111. * boolean flip the sprite after its been repositioned by the framing data.
  70112. */
  70113. flipU?: boolean;
  70114. /**
  70115. * Vector3 scalar of the global RGB values of the SpriteMap.
  70116. */
  70117. colorMultiply?: Vector3;
  70118. }
  70119. /**
  70120. * Defines the IDisposable interface in order to be cleanable from resources.
  70121. */
  70122. export interface ISpriteMap extends IDisposable {
  70123. /**
  70124. * String name of the SpriteMap.
  70125. */
  70126. name: string;
  70127. /**
  70128. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70129. */
  70130. atlasJSON: ISpriteJSONAtlas;
  70131. /**
  70132. * Texture of the SpriteMap.
  70133. */
  70134. spriteSheet: Texture;
  70135. /**
  70136. * The parameters to initialize the SpriteMap with.
  70137. */
  70138. options: ISpriteMapOptions;
  70139. }
  70140. /**
  70141. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70142. */
  70143. export class SpriteMap implements ISpriteMap {
  70144. /** The Name of the spriteMap */
  70145. name: string;
  70146. /** The JSON file with the frame and meta data */
  70147. atlasJSON: ISpriteJSONAtlas;
  70148. /** The systems Sprite Sheet Texture */
  70149. spriteSheet: Texture;
  70150. /** Arguments passed with the Constructor */
  70151. options: ISpriteMapOptions;
  70152. /** Public Sprite Storage array, parsed from atlasJSON */
  70153. sprites: Array<ISpriteJSONSprite>;
  70154. /** Returns the Number of Sprites in the System */
  70155. get spriteCount(): number;
  70156. /** Returns the Position of Output Plane*/
  70157. get position(): Vector3;
  70158. /** Returns the Position of Output Plane*/
  70159. set position(v: Vector3);
  70160. /** Returns the Rotation of Output Plane*/
  70161. get rotation(): Vector3;
  70162. /** Returns the Rotation of Output Plane*/
  70163. set rotation(v: Vector3);
  70164. /** Sets the AnimationMap*/
  70165. get animationMap(): RawTexture;
  70166. /** Sets the AnimationMap*/
  70167. set animationMap(v: RawTexture);
  70168. /** Scene that the SpriteMap was created in */
  70169. private _scene;
  70170. /** Texture Buffer of Float32 that holds tile frame data*/
  70171. private _frameMap;
  70172. /** Texture Buffers of Float32 that holds tileMap data*/
  70173. private _tileMaps;
  70174. /** Texture Buffer of Float32 that holds Animation Data*/
  70175. private _animationMap;
  70176. /** Custom ShaderMaterial Central to the System*/
  70177. private _material;
  70178. /** Custom ShaderMaterial Central to the System*/
  70179. private _output;
  70180. /** Systems Time Ticker*/
  70181. private _time;
  70182. /**
  70183. * Creates a new SpriteMap
  70184. * @param name defines the SpriteMaps Name
  70185. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70186. * @param spriteSheet is the Texture that the Sprites are on.
  70187. * @param options a basic deployment configuration
  70188. * @param scene The Scene that the map is deployed on
  70189. */
  70190. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70191. /**
  70192. * Returns tileID location
  70193. * @returns Vector2 the cell position ID
  70194. */
  70195. getTileID(): Vector2;
  70196. /**
  70197. * Gets the UV location of the mouse over the SpriteMap.
  70198. * @returns Vector2 the UV position of the mouse interaction
  70199. */
  70200. getMousePosition(): Vector2;
  70201. /**
  70202. * Creates the "frame" texture Buffer
  70203. * -------------------------------------
  70204. * Structure of frames
  70205. * "filename": "Falling-Water-2.png",
  70206. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70207. * "rotated": true,
  70208. * "trimmed": true,
  70209. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70210. * "sourceSize": {"w":32,"h":32}
  70211. * @returns RawTexture of the frameMap
  70212. */
  70213. private _createFrameBuffer;
  70214. /**
  70215. * Creates the tileMap texture Buffer
  70216. * @param buffer normally and array of numbers, or a false to generate from scratch
  70217. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70218. * @returns RawTexture of the tileMap
  70219. */
  70220. private _createTileBuffer;
  70221. /**
  70222. * Modifies the data of the tileMaps
  70223. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70224. * @param pos is the iVector2 Coordinates of the Tile
  70225. * @param tile The SpriteIndex of the new Tile
  70226. */
  70227. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70228. /**
  70229. * Creates the animationMap texture Buffer
  70230. * @param buffer normally and array of numbers, or a false to generate from scratch
  70231. * @returns RawTexture of the animationMap
  70232. */
  70233. private _createTileAnimationBuffer;
  70234. /**
  70235. * Modifies the data of the animationMap
  70236. * @param cellID is the Index of the Sprite
  70237. * @param _frame is the target Animation frame
  70238. * @param toCell is the Target Index of the next frame of the animation
  70239. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70240. * @param speed is a global scalar of the time variable on the map.
  70241. */
  70242. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70243. /**
  70244. * Exports the .tilemaps file
  70245. */
  70246. saveTileMaps(): void;
  70247. /**
  70248. * Imports the .tilemaps file
  70249. * @param url of the .tilemaps file
  70250. */
  70251. loadTileMaps(url: string): void;
  70252. /**
  70253. * Release associated resources
  70254. */
  70255. dispose(): void;
  70256. }
  70257. }
  70258. declare module BABYLON {
  70259. /**
  70260. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70261. * @see http://doc.babylonjs.com/babylon101/sprites
  70262. */
  70263. export class SpritePackedManager extends SpriteManager {
  70264. /** defines the packed manager's name */
  70265. name: string;
  70266. /**
  70267. * Creates a new sprite manager from a packed sprite sheet
  70268. * @param name defines the manager's name
  70269. * @param imgUrl defines the sprite sheet url
  70270. * @param capacity defines the maximum allowed number of sprites
  70271. * @param scene defines the hosting scene
  70272. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70273. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70274. * @param samplingMode defines the smapling mode to use with spritesheet
  70275. * @param fromPacked set to true; do not alter
  70276. */
  70277. constructor(
  70278. /** defines the packed manager's name */
  70279. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70280. }
  70281. }
  70282. declare module BABYLON {
  70283. /**
  70284. * Defines the list of states available for a task inside a AssetsManager
  70285. */
  70286. export enum AssetTaskState {
  70287. /**
  70288. * Initialization
  70289. */
  70290. INIT = 0,
  70291. /**
  70292. * Running
  70293. */
  70294. RUNNING = 1,
  70295. /**
  70296. * Done
  70297. */
  70298. DONE = 2,
  70299. /**
  70300. * Error
  70301. */
  70302. ERROR = 3
  70303. }
  70304. /**
  70305. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70306. */
  70307. export abstract class AbstractAssetTask {
  70308. /**
  70309. * Task name
  70310. */ name: string;
  70311. /**
  70312. * Callback called when the task is successful
  70313. */
  70314. onSuccess: (task: any) => void;
  70315. /**
  70316. * Callback called when the task is not successful
  70317. */
  70318. onError: (task: any, message?: string, exception?: any) => void;
  70319. /**
  70320. * Creates a new AssetsManager
  70321. * @param name defines the name of the task
  70322. */
  70323. constructor(
  70324. /**
  70325. * Task name
  70326. */ name: string);
  70327. private _isCompleted;
  70328. private _taskState;
  70329. private _errorObject;
  70330. /**
  70331. * Get if the task is completed
  70332. */
  70333. get isCompleted(): boolean;
  70334. /**
  70335. * Gets the current state of the task
  70336. */
  70337. get taskState(): AssetTaskState;
  70338. /**
  70339. * Gets the current error object (if task is in error)
  70340. */
  70341. get errorObject(): {
  70342. message?: string;
  70343. exception?: any;
  70344. };
  70345. /**
  70346. * Internal only
  70347. * @hidden
  70348. */
  70349. _setErrorObject(message?: string, exception?: any): void;
  70350. /**
  70351. * Execute the current task
  70352. * @param scene defines the scene where you want your assets to be loaded
  70353. * @param onSuccess is a callback called when the task is successfully executed
  70354. * @param onError is a callback called if an error occurs
  70355. */
  70356. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70357. /**
  70358. * Execute the current task
  70359. * @param scene defines the scene where you want your assets to be loaded
  70360. * @param onSuccess is a callback called when the task is successfully executed
  70361. * @param onError is a callback called if an error occurs
  70362. */
  70363. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70364. /**
  70365. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70366. * This can be used with failed tasks that have the reason for failure fixed.
  70367. */
  70368. reset(): void;
  70369. private onErrorCallback;
  70370. private onDoneCallback;
  70371. }
  70372. /**
  70373. * Define the interface used by progress events raised during assets loading
  70374. */
  70375. export interface IAssetsProgressEvent {
  70376. /**
  70377. * Defines the number of remaining tasks to process
  70378. */
  70379. remainingCount: number;
  70380. /**
  70381. * Defines the total number of tasks
  70382. */
  70383. totalCount: number;
  70384. /**
  70385. * Defines the task that was just processed
  70386. */
  70387. task: AbstractAssetTask;
  70388. }
  70389. /**
  70390. * Class used to share progress information about assets loading
  70391. */
  70392. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70393. /**
  70394. * Defines the number of remaining tasks to process
  70395. */
  70396. remainingCount: number;
  70397. /**
  70398. * Defines the total number of tasks
  70399. */
  70400. totalCount: number;
  70401. /**
  70402. * Defines the task that was just processed
  70403. */
  70404. task: AbstractAssetTask;
  70405. /**
  70406. * Creates a AssetsProgressEvent
  70407. * @param remainingCount defines the number of remaining tasks to process
  70408. * @param totalCount defines the total number of tasks
  70409. * @param task defines the task that was just processed
  70410. */
  70411. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70412. }
  70413. /**
  70414. * Define a task used by AssetsManager to load meshes
  70415. */
  70416. export class MeshAssetTask extends AbstractAssetTask {
  70417. /**
  70418. * Defines the name of the task
  70419. */
  70420. name: string;
  70421. /**
  70422. * Defines the list of mesh's names you want to load
  70423. */
  70424. meshesNames: any;
  70425. /**
  70426. * Defines the root url to use as a base to load your meshes and associated resources
  70427. */
  70428. rootUrl: string;
  70429. /**
  70430. * Defines the filename or File of the scene to load from
  70431. */
  70432. sceneFilename: string | File;
  70433. /**
  70434. * Gets the list of loaded meshes
  70435. */
  70436. loadedMeshes: Array<AbstractMesh>;
  70437. /**
  70438. * Gets the list of loaded particle systems
  70439. */
  70440. loadedParticleSystems: Array<IParticleSystem>;
  70441. /**
  70442. * Gets the list of loaded skeletons
  70443. */
  70444. loadedSkeletons: Array<Skeleton>;
  70445. /**
  70446. * Gets the list of loaded animation groups
  70447. */
  70448. loadedAnimationGroups: Array<AnimationGroup>;
  70449. /**
  70450. * Callback called when the task is successful
  70451. */
  70452. onSuccess: (task: MeshAssetTask) => void;
  70453. /**
  70454. * Callback called when the task is successful
  70455. */
  70456. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70457. /**
  70458. * Creates a new MeshAssetTask
  70459. * @param name defines the name of the task
  70460. * @param meshesNames defines the list of mesh's names you want to load
  70461. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70462. * @param sceneFilename defines the filename or File of the scene to load from
  70463. */
  70464. constructor(
  70465. /**
  70466. * Defines the name of the task
  70467. */
  70468. name: string,
  70469. /**
  70470. * Defines the list of mesh's names you want to load
  70471. */
  70472. meshesNames: any,
  70473. /**
  70474. * Defines the root url to use as a base to load your meshes and associated resources
  70475. */
  70476. rootUrl: string,
  70477. /**
  70478. * Defines the filename or File of the scene to load from
  70479. */
  70480. sceneFilename: string | File);
  70481. /**
  70482. * Execute the current task
  70483. * @param scene defines the scene where you want your assets to be loaded
  70484. * @param onSuccess is a callback called when the task is successfully executed
  70485. * @param onError is a callback called if an error occurs
  70486. */
  70487. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70488. }
  70489. /**
  70490. * Define a task used by AssetsManager to load text content
  70491. */
  70492. export class TextFileAssetTask extends AbstractAssetTask {
  70493. /**
  70494. * Defines the name of the task
  70495. */
  70496. name: string;
  70497. /**
  70498. * Defines the location of the file to load
  70499. */
  70500. url: string;
  70501. /**
  70502. * Gets the loaded text string
  70503. */
  70504. text: string;
  70505. /**
  70506. * Callback called when the task is successful
  70507. */
  70508. onSuccess: (task: TextFileAssetTask) => void;
  70509. /**
  70510. * Callback called when the task is successful
  70511. */
  70512. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70513. /**
  70514. * Creates a new TextFileAssetTask object
  70515. * @param name defines the name of the task
  70516. * @param url defines the location of the file to load
  70517. */
  70518. constructor(
  70519. /**
  70520. * Defines the name of the task
  70521. */
  70522. name: string,
  70523. /**
  70524. * Defines the location of the file to load
  70525. */
  70526. url: string);
  70527. /**
  70528. * Execute the current task
  70529. * @param scene defines the scene where you want your assets to be loaded
  70530. * @param onSuccess is a callback called when the task is successfully executed
  70531. * @param onError is a callback called if an error occurs
  70532. */
  70533. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70534. }
  70535. /**
  70536. * Define a task used by AssetsManager to load binary data
  70537. */
  70538. export class BinaryFileAssetTask extends AbstractAssetTask {
  70539. /**
  70540. * Defines the name of the task
  70541. */
  70542. name: string;
  70543. /**
  70544. * Defines the location of the file to load
  70545. */
  70546. url: string;
  70547. /**
  70548. * Gets the lodaded data (as an array buffer)
  70549. */
  70550. data: ArrayBuffer;
  70551. /**
  70552. * Callback called when the task is successful
  70553. */
  70554. onSuccess: (task: BinaryFileAssetTask) => void;
  70555. /**
  70556. * Callback called when the task is successful
  70557. */
  70558. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70559. /**
  70560. * Creates a new BinaryFileAssetTask object
  70561. * @param name defines the name of the new task
  70562. * @param url defines the location of the file to load
  70563. */
  70564. constructor(
  70565. /**
  70566. * Defines the name of the task
  70567. */
  70568. name: string,
  70569. /**
  70570. * Defines the location of the file to load
  70571. */
  70572. url: string);
  70573. /**
  70574. * Execute the current task
  70575. * @param scene defines the scene where you want your assets to be loaded
  70576. * @param onSuccess is a callback called when the task is successfully executed
  70577. * @param onError is a callback called if an error occurs
  70578. */
  70579. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70580. }
  70581. /**
  70582. * Define a task used by AssetsManager to load images
  70583. */
  70584. export class ImageAssetTask extends AbstractAssetTask {
  70585. /**
  70586. * Defines the name of the task
  70587. */
  70588. name: string;
  70589. /**
  70590. * Defines the location of the image to load
  70591. */
  70592. url: string;
  70593. /**
  70594. * Gets the loaded images
  70595. */
  70596. image: HTMLImageElement;
  70597. /**
  70598. * Callback called when the task is successful
  70599. */
  70600. onSuccess: (task: ImageAssetTask) => void;
  70601. /**
  70602. * Callback called when the task is successful
  70603. */
  70604. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70605. /**
  70606. * Creates a new ImageAssetTask
  70607. * @param name defines the name of the task
  70608. * @param url defines the location of the image to load
  70609. */
  70610. constructor(
  70611. /**
  70612. * Defines the name of the task
  70613. */
  70614. name: string,
  70615. /**
  70616. * Defines the location of the image to load
  70617. */
  70618. url: string);
  70619. /**
  70620. * Execute the current task
  70621. * @param scene defines the scene where you want your assets to be loaded
  70622. * @param onSuccess is a callback called when the task is successfully executed
  70623. * @param onError is a callback called if an error occurs
  70624. */
  70625. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70626. }
  70627. /**
  70628. * Defines the interface used by texture loading tasks
  70629. */
  70630. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70631. /**
  70632. * Gets the loaded texture
  70633. */
  70634. texture: TEX;
  70635. }
  70636. /**
  70637. * Define a task used by AssetsManager to load 2D textures
  70638. */
  70639. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70640. /**
  70641. * Defines the name of the task
  70642. */
  70643. name: string;
  70644. /**
  70645. * Defines the location of the file to load
  70646. */
  70647. url: string;
  70648. /**
  70649. * Defines if mipmap should not be generated (default is false)
  70650. */
  70651. noMipmap?: boolean | undefined;
  70652. /**
  70653. * Defines if texture must be inverted on Y axis (default is true)
  70654. */
  70655. invertY: boolean;
  70656. /**
  70657. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70658. */
  70659. samplingMode: number;
  70660. /**
  70661. * Gets the loaded texture
  70662. */
  70663. texture: Texture;
  70664. /**
  70665. * Callback called when the task is successful
  70666. */
  70667. onSuccess: (task: TextureAssetTask) => void;
  70668. /**
  70669. * Callback called when the task is successful
  70670. */
  70671. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70672. /**
  70673. * Creates a new TextureAssetTask object
  70674. * @param name defines the name of the task
  70675. * @param url defines the location of the file to load
  70676. * @param noMipmap defines if mipmap should not be generated (default is false)
  70677. * @param invertY defines if texture must be inverted on Y axis (default is true)
  70678. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70679. */
  70680. constructor(
  70681. /**
  70682. * Defines the name of the task
  70683. */
  70684. name: string,
  70685. /**
  70686. * Defines the location of the file to load
  70687. */
  70688. url: string,
  70689. /**
  70690. * Defines if mipmap should not be generated (default is false)
  70691. */
  70692. noMipmap?: boolean | undefined,
  70693. /**
  70694. * Defines if texture must be inverted on Y axis (default is true)
  70695. */
  70696. invertY?: boolean,
  70697. /**
  70698. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70699. */
  70700. samplingMode?: number);
  70701. /**
  70702. * Execute the current task
  70703. * @param scene defines the scene where you want your assets to be loaded
  70704. * @param onSuccess is a callback called when the task is successfully executed
  70705. * @param onError is a callback called if an error occurs
  70706. */
  70707. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70708. }
  70709. /**
  70710. * Define a task used by AssetsManager to load cube textures
  70711. */
  70712. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  70713. /**
  70714. * Defines the name of the task
  70715. */
  70716. name: string;
  70717. /**
  70718. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70719. */
  70720. url: string;
  70721. /**
  70722. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70723. */
  70724. extensions?: string[] | undefined;
  70725. /**
  70726. * Defines if mipmaps should not be generated (default is false)
  70727. */
  70728. noMipmap?: boolean | undefined;
  70729. /**
  70730. * Defines the explicit list of files (undefined by default)
  70731. */
  70732. files?: string[] | undefined;
  70733. /**
  70734. * Gets the loaded texture
  70735. */
  70736. texture: CubeTexture;
  70737. /**
  70738. * Callback called when the task is successful
  70739. */
  70740. onSuccess: (task: CubeTextureAssetTask) => void;
  70741. /**
  70742. * Callback called when the task is successful
  70743. */
  70744. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  70745. /**
  70746. * Creates a new CubeTextureAssetTask
  70747. * @param name defines the name of the task
  70748. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70749. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70750. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70751. * @param files defines the explicit list of files (undefined by default)
  70752. */
  70753. constructor(
  70754. /**
  70755. * Defines the name of the task
  70756. */
  70757. name: string,
  70758. /**
  70759. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70760. */
  70761. url: string,
  70762. /**
  70763. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70764. */
  70765. extensions?: string[] | undefined,
  70766. /**
  70767. * Defines if mipmaps should not be generated (default is false)
  70768. */
  70769. noMipmap?: boolean | undefined,
  70770. /**
  70771. * Defines the explicit list of files (undefined by default)
  70772. */
  70773. files?: string[] | undefined);
  70774. /**
  70775. * Execute the current task
  70776. * @param scene defines the scene where you want your assets to be loaded
  70777. * @param onSuccess is a callback called when the task is successfully executed
  70778. * @param onError is a callback called if an error occurs
  70779. */
  70780. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70781. }
  70782. /**
  70783. * Define a task used by AssetsManager to load HDR cube textures
  70784. */
  70785. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  70786. /**
  70787. * Defines the name of the task
  70788. */
  70789. name: string;
  70790. /**
  70791. * Defines the location of the file to load
  70792. */
  70793. url: string;
  70794. /**
  70795. * Defines the desired size (the more it increases the longer the generation will be)
  70796. */
  70797. size: number;
  70798. /**
  70799. * Defines if mipmaps should not be generated (default is false)
  70800. */
  70801. noMipmap: boolean;
  70802. /**
  70803. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70804. */
  70805. generateHarmonics: boolean;
  70806. /**
  70807. * 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)
  70808. */
  70809. gammaSpace: boolean;
  70810. /**
  70811. * Internal Use Only
  70812. */
  70813. reserved: boolean;
  70814. /**
  70815. * Gets the loaded texture
  70816. */
  70817. texture: HDRCubeTexture;
  70818. /**
  70819. * Callback called when the task is successful
  70820. */
  70821. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  70822. /**
  70823. * Callback called when the task is successful
  70824. */
  70825. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  70826. /**
  70827. * Creates a new HDRCubeTextureAssetTask object
  70828. * @param name defines the name of the task
  70829. * @param url defines the location of the file to load
  70830. * @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.
  70831. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70832. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70833. * @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)
  70834. * @param reserved Internal use only
  70835. */
  70836. constructor(
  70837. /**
  70838. * Defines the name of the task
  70839. */
  70840. name: string,
  70841. /**
  70842. * Defines the location of the file to load
  70843. */
  70844. url: string,
  70845. /**
  70846. * Defines the desired size (the more it increases the longer the generation will be)
  70847. */
  70848. size: number,
  70849. /**
  70850. * Defines if mipmaps should not be generated (default is false)
  70851. */
  70852. noMipmap?: boolean,
  70853. /**
  70854. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70855. */
  70856. generateHarmonics?: boolean,
  70857. /**
  70858. * 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)
  70859. */
  70860. gammaSpace?: boolean,
  70861. /**
  70862. * Internal Use Only
  70863. */
  70864. reserved?: boolean);
  70865. /**
  70866. * Execute the current task
  70867. * @param scene defines the scene where you want your assets to be loaded
  70868. * @param onSuccess is a callback called when the task is successfully executed
  70869. * @param onError is a callback called if an error occurs
  70870. */
  70871. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70872. }
  70873. /**
  70874. * Define a task used by AssetsManager to load Equirectangular cube textures
  70875. */
  70876. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  70877. /**
  70878. * Defines the name of the task
  70879. */
  70880. name: string;
  70881. /**
  70882. * Defines the location of the file to load
  70883. */
  70884. url: string;
  70885. /**
  70886. * Defines the desired size (the more it increases the longer the generation will be)
  70887. */
  70888. size: number;
  70889. /**
  70890. * Defines if mipmaps should not be generated (default is false)
  70891. */
  70892. noMipmap: boolean;
  70893. /**
  70894. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70895. * but the standard material would require them in Gamma space) (default is true)
  70896. */
  70897. gammaSpace: boolean;
  70898. /**
  70899. * Gets the loaded texture
  70900. */
  70901. texture: EquiRectangularCubeTexture;
  70902. /**
  70903. * Callback called when the task is successful
  70904. */
  70905. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  70906. /**
  70907. * Callback called when the task is successful
  70908. */
  70909. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  70910. /**
  70911. * Creates a new EquiRectangularCubeTextureAssetTask object
  70912. * @param name defines the name of the task
  70913. * @param url defines the location of the file to load
  70914. * @param size defines the desired size (the more it increases the longer the generation will be)
  70915. * If the size is omitted this implies you are using a preprocessed cubemap.
  70916. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70917. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  70918. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  70919. * (default is true)
  70920. */
  70921. constructor(
  70922. /**
  70923. * Defines the name of the task
  70924. */
  70925. name: string,
  70926. /**
  70927. * Defines the location of the file to load
  70928. */
  70929. url: string,
  70930. /**
  70931. * Defines the desired size (the more it increases the longer the generation will be)
  70932. */
  70933. size: number,
  70934. /**
  70935. * Defines if mipmaps should not be generated (default is false)
  70936. */
  70937. noMipmap?: boolean,
  70938. /**
  70939. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70940. * but the standard material would require them in Gamma space) (default is true)
  70941. */
  70942. gammaSpace?: boolean);
  70943. /**
  70944. * Execute the current task
  70945. * @param scene defines the scene where you want your assets to be loaded
  70946. * @param onSuccess is a callback called when the task is successfully executed
  70947. * @param onError is a callback called if an error occurs
  70948. */
  70949. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70950. }
  70951. /**
  70952. * This class can be used to easily import assets into a scene
  70953. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  70954. */
  70955. export class AssetsManager {
  70956. private _scene;
  70957. private _isLoading;
  70958. protected _tasks: AbstractAssetTask[];
  70959. protected _waitingTasksCount: number;
  70960. protected _totalTasksCount: number;
  70961. /**
  70962. * Callback called when all tasks are processed
  70963. */
  70964. onFinish: (tasks: AbstractAssetTask[]) => void;
  70965. /**
  70966. * Callback called when a task is successful
  70967. */
  70968. onTaskSuccess: (task: AbstractAssetTask) => void;
  70969. /**
  70970. * Callback called when a task had an error
  70971. */
  70972. onTaskError: (task: AbstractAssetTask) => void;
  70973. /**
  70974. * Callback called when a task is done (whatever the result is)
  70975. */
  70976. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  70977. /**
  70978. * Observable called when all tasks are processed
  70979. */
  70980. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  70981. /**
  70982. * Observable called when a task had an error
  70983. */
  70984. onTaskErrorObservable: Observable<AbstractAssetTask>;
  70985. /**
  70986. * Observable called when all tasks were executed
  70987. */
  70988. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  70989. /**
  70990. * Observable called when a task is done (whatever the result is)
  70991. */
  70992. onProgressObservable: Observable<IAssetsProgressEvent>;
  70993. /**
  70994. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  70995. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  70996. */
  70997. useDefaultLoadingScreen: boolean;
  70998. /**
  70999. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71000. * when all assets have been downloaded.
  71001. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71002. */
  71003. autoHideLoadingUI: boolean;
  71004. /**
  71005. * Creates a new AssetsManager
  71006. * @param scene defines the scene to work on
  71007. */
  71008. constructor(scene: Scene);
  71009. /**
  71010. * Add a MeshAssetTask to the list of active tasks
  71011. * @param taskName defines the name of the new task
  71012. * @param meshesNames defines the name of meshes to load
  71013. * @param rootUrl defines the root url to use to locate files
  71014. * @param sceneFilename defines the filename of the scene file
  71015. * @returns a new MeshAssetTask object
  71016. */
  71017. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71018. /**
  71019. * Add a TextFileAssetTask to the list of active tasks
  71020. * @param taskName defines the name of the new task
  71021. * @param url defines the url of the file to load
  71022. * @returns a new TextFileAssetTask object
  71023. */
  71024. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71025. /**
  71026. * Add a BinaryFileAssetTask to the list of active tasks
  71027. * @param taskName defines the name of the new task
  71028. * @param url defines the url of the file to load
  71029. * @returns a new BinaryFileAssetTask object
  71030. */
  71031. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71032. /**
  71033. * Add a ImageAssetTask to the list of active tasks
  71034. * @param taskName defines the name of the new task
  71035. * @param url defines the url of the file to load
  71036. * @returns a new ImageAssetTask object
  71037. */
  71038. addImageTask(taskName: string, url: string): ImageAssetTask;
  71039. /**
  71040. * Add a TextureAssetTask to the list of active tasks
  71041. * @param taskName defines the name of the new task
  71042. * @param url defines the url of the file to load
  71043. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71044. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71045. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71046. * @returns a new TextureAssetTask object
  71047. */
  71048. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71049. /**
  71050. * Add a CubeTextureAssetTask to the list of active tasks
  71051. * @param taskName defines the name of the new task
  71052. * @param url defines the url of the file to load
  71053. * @param extensions defines the extension to use to load the cube map (can be null)
  71054. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71055. * @param files defines the list of files to load (can be null)
  71056. * @returns a new CubeTextureAssetTask object
  71057. */
  71058. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71059. /**
  71060. *
  71061. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71062. * @param taskName defines the name of the new task
  71063. * @param url defines the url of the file to load
  71064. * @param size defines the size you want for the cubemap (can be null)
  71065. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71066. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71067. * @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)
  71068. * @param reserved Internal use only
  71069. * @returns a new HDRCubeTextureAssetTask object
  71070. */
  71071. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71072. /**
  71073. *
  71074. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71075. * @param taskName defines the name of the new task
  71076. * @param url defines the url of the file to load
  71077. * @param size defines the size you want for the cubemap (can be null)
  71078. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71079. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71080. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71081. * @returns a new EquiRectangularCubeTextureAssetTask object
  71082. */
  71083. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71084. /**
  71085. * Remove a task from the assets manager.
  71086. * @param task the task to remove
  71087. */
  71088. removeTask(task: AbstractAssetTask): void;
  71089. private _decreaseWaitingTasksCount;
  71090. private _runTask;
  71091. /**
  71092. * Reset the AssetsManager and remove all tasks
  71093. * @return the current instance of the AssetsManager
  71094. */
  71095. reset(): AssetsManager;
  71096. /**
  71097. * Start the loading process
  71098. * @return the current instance of the AssetsManager
  71099. */
  71100. load(): AssetsManager;
  71101. /**
  71102. * Start the loading process as an async operation
  71103. * @return a promise returning the list of failed tasks
  71104. */
  71105. loadAsync(): Promise<void>;
  71106. }
  71107. }
  71108. declare module BABYLON {
  71109. /**
  71110. * Wrapper class for promise with external resolve and reject.
  71111. */
  71112. export class Deferred<T> {
  71113. /**
  71114. * The promise associated with this deferred object.
  71115. */
  71116. readonly promise: Promise<T>;
  71117. private _resolve;
  71118. private _reject;
  71119. /**
  71120. * The resolve method of the promise associated with this deferred object.
  71121. */
  71122. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71123. /**
  71124. * The reject method of the promise associated with this deferred object.
  71125. */
  71126. get reject(): (reason?: any) => void;
  71127. /**
  71128. * Constructor for this deferred object.
  71129. */
  71130. constructor();
  71131. }
  71132. }
  71133. declare module BABYLON {
  71134. /**
  71135. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71136. */
  71137. export class MeshExploder {
  71138. private _centerMesh;
  71139. private _meshes;
  71140. private _meshesOrigins;
  71141. private _toCenterVectors;
  71142. private _scaledDirection;
  71143. private _newPosition;
  71144. private _centerPosition;
  71145. /**
  71146. * Explodes meshes from a center mesh.
  71147. * @param meshes The meshes to explode.
  71148. * @param centerMesh The mesh to be center of explosion.
  71149. */
  71150. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71151. private _setCenterMesh;
  71152. /**
  71153. * Get class name
  71154. * @returns "MeshExploder"
  71155. */
  71156. getClassName(): string;
  71157. /**
  71158. * "Exploded meshes"
  71159. * @returns Array of meshes with the centerMesh at index 0.
  71160. */
  71161. getMeshes(): Array<Mesh>;
  71162. /**
  71163. * Explodes meshes giving a specific direction
  71164. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71165. */
  71166. explode(direction?: number): void;
  71167. }
  71168. }
  71169. declare module BABYLON {
  71170. /**
  71171. * Class used to help managing file picking and drag'n'drop
  71172. */
  71173. export class FilesInput {
  71174. /**
  71175. * List of files ready to be loaded
  71176. */
  71177. static get FilesToLoad(): {
  71178. [key: string]: File;
  71179. };
  71180. /**
  71181. * Callback called when a file is processed
  71182. */
  71183. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71184. private _engine;
  71185. private _currentScene;
  71186. private _sceneLoadedCallback;
  71187. private _progressCallback;
  71188. private _additionalRenderLoopLogicCallback;
  71189. private _textureLoadingCallback;
  71190. private _startingProcessingFilesCallback;
  71191. private _onReloadCallback;
  71192. private _errorCallback;
  71193. private _elementToMonitor;
  71194. private _sceneFileToLoad;
  71195. private _filesToLoad;
  71196. /**
  71197. * Creates a new FilesInput
  71198. * @param engine defines the rendering engine
  71199. * @param scene defines the hosting scene
  71200. * @param sceneLoadedCallback callback called when scene is loaded
  71201. * @param progressCallback callback called to track progress
  71202. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71203. * @param textureLoadingCallback callback called when a texture is loading
  71204. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71205. * @param onReloadCallback callback called when a reload is requested
  71206. * @param errorCallback callback call if an error occurs
  71207. */
  71208. 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);
  71209. private _dragEnterHandler;
  71210. private _dragOverHandler;
  71211. private _dropHandler;
  71212. /**
  71213. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71214. * @param elementToMonitor defines the DOM element to track
  71215. */
  71216. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71217. /**
  71218. * Release all associated resources
  71219. */
  71220. dispose(): void;
  71221. private renderFunction;
  71222. private drag;
  71223. private drop;
  71224. private _traverseFolder;
  71225. private _processFiles;
  71226. /**
  71227. * Load files from a drop event
  71228. * @param event defines the drop event to use as source
  71229. */
  71230. loadFiles(event: any): void;
  71231. private _processReload;
  71232. /**
  71233. * Reload the current scene from the loaded files
  71234. */
  71235. reload(): void;
  71236. }
  71237. }
  71238. declare module BABYLON {
  71239. /**
  71240. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71241. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71242. */
  71243. export class SceneOptimization {
  71244. /**
  71245. * Defines the priority of this optimization (0 by default which means first in the list)
  71246. */
  71247. priority: number;
  71248. /**
  71249. * Gets a string describing the action executed by the current optimization
  71250. * @returns description string
  71251. */
  71252. getDescription(): string;
  71253. /**
  71254. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71255. * @param scene defines the current scene where to apply this optimization
  71256. * @param optimizer defines the current optimizer
  71257. * @returns true if everything that can be done was applied
  71258. */
  71259. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71260. /**
  71261. * Creates the SceneOptimization object
  71262. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71263. * @param desc defines the description associated with the optimization
  71264. */
  71265. constructor(
  71266. /**
  71267. * Defines the priority of this optimization (0 by default which means first in the list)
  71268. */
  71269. priority?: number);
  71270. }
  71271. /**
  71272. * Defines an optimization used to reduce the size of render target textures
  71273. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71274. */
  71275. export class TextureOptimization extends SceneOptimization {
  71276. /**
  71277. * Defines the priority of this optimization (0 by default which means first in the list)
  71278. */
  71279. priority: number;
  71280. /**
  71281. * 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
  71282. */
  71283. maximumSize: number;
  71284. /**
  71285. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71286. */
  71287. step: number;
  71288. /**
  71289. * Gets a string describing the action executed by the current optimization
  71290. * @returns description string
  71291. */
  71292. getDescription(): string;
  71293. /**
  71294. * Creates the TextureOptimization object
  71295. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71296. * @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
  71297. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71298. */
  71299. constructor(
  71300. /**
  71301. * Defines the priority of this optimization (0 by default which means first in the list)
  71302. */
  71303. priority?: number,
  71304. /**
  71305. * 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
  71306. */
  71307. maximumSize?: number,
  71308. /**
  71309. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71310. */
  71311. step?: number);
  71312. /**
  71313. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71314. * @param scene defines the current scene where to apply this optimization
  71315. * @param optimizer defines the current optimizer
  71316. * @returns true if everything that can be done was applied
  71317. */
  71318. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71319. }
  71320. /**
  71321. * Defines an optimization used to increase or decrease the rendering resolution
  71322. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71323. */
  71324. export class HardwareScalingOptimization extends SceneOptimization {
  71325. /**
  71326. * Defines the priority of this optimization (0 by default which means first in the list)
  71327. */
  71328. priority: number;
  71329. /**
  71330. * Defines the maximum scale to use (2 by default)
  71331. */
  71332. maximumScale: number;
  71333. /**
  71334. * Defines the step to use between two passes (0.5 by default)
  71335. */
  71336. step: number;
  71337. private _currentScale;
  71338. private _directionOffset;
  71339. /**
  71340. * Gets a string describing the action executed by the current optimization
  71341. * @return description string
  71342. */
  71343. getDescription(): string;
  71344. /**
  71345. * Creates the HardwareScalingOptimization object
  71346. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71347. * @param maximumScale defines the maximum scale to use (2 by default)
  71348. * @param step defines the step to use between two passes (0.5 by default)
  71349. */
  71350. constructor(
  71351. /**
  71352. * Defines the priority of this optimization (0 by default which means first in the list)
  71353. */
  71354. priority?: number,
  71355. /**
  71356. * Defines the maximum scale to use (2 by default)
  71357. */
  71358. maximumScale?: number,
  71359. /**
  71360. * Defines the step to use between two passes (0.5 by default)
  71361. */
  71362. step?: number);
  71363. /**
  71364. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71365. * @param scene defines the current scene where to apply this optimization
  71366. * @param optimizer defines the current optimizer
  71367. * @returns true if everything that can be done was applied
  71368. */
  71369. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71370. }
  71371. /**
  71372. * Defines an optimization used to remove shadows
  71373. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71374. */
  71375. export class ShadowsOptimization extends SceneOptimization {
  71376. /**
  71377. * Gets a string describing the action executed by the current optimization
  71378. * @return description string
  71379. */
  71380. getDescription(): string;
  71381. /**
  71382. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71383. * @param scene defines the current scene where to apply this optimization
  71384. * @param optimizer defines the current optimizer
  71385. * @returns true if everything that can be done was applied
  71386. */
  71387. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71388. }
  71389. /**
  71390. * Defines an optimization used to turn post-processes off
  71391. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71392. */
  71393. export class PostProcessesOptimization extends SceneOptimization {
  71394. /**
  71395. * Gets a string describing the action executed by the current optimization
  71396. * @return description string
  71397. */
  71398. getDescription(): string;
  71399. /**
  71400. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71401. * @param scene defines the current scene where to apply this optimization
  71402. * @param optimizer defines the current optimizer
  71403. * @returns true if everything that can be done was applied
  71404. */
  71405. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71406. }
  71407. /**
  71408. * Defines an optimization used to turn lens flares off
  71409. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71410. */
  71411. export class LensFlaresOptimization extends SceneOptimization {
  71412. /**
  71413. * Gets a string describing the action executed by the current optimization
  71414. * @return description string
  71415. */
  71416. getDescription(): string;
  71417. /**
  71418. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71419. * @param scene defines the current scene where to apply this optimization
  71420. * @param optimizer defines the current optimizer
  71421. * @returns true if everything that can be done was applied
  71422. */
  71423. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71424. }
  71425. /**
  71426. * Defines an optimization based on user defined callback.
  71427. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71428. */
  71429. export class CustomOptimization extends SceneOptimization {
  71430. /**
  71431. * Callback called to apply the custom optimization.
  71432. */
  71433. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71434. /**
  71435. * Callback called to get custom description
  71436. */
  71437. onGetDescription: () => string;
  71438. /**
  71439. * Gets a string describing the action executed by the current optimization
  71440. * @returns description string
  71441. */
  71442. getDescription(): string;
  71443. /**
  71444. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71445. * @param scene defines the current scene where to apply this optimization
  71446. * @param optimizer defines the current optimizer
  71447. * @returns true if everything that can be done was applied
  71448. */
  71449. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71450. }
  71451. /**
  71452. * Defines an optimization used to turn particles off
  71453. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71454. */
  71455. export class ParticlesOptimization extends SceneOptimization {
  71456. /**
  71457. * Gets a string describing the action executed by the current optimization
  71458. * @return description string
  71459. */
  71460. getDescription(): string;
  71461. /**
  71462. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71463. * @param scene defines the current scene where to apply this optimization
  71464. * @param optimizer defines the current optimizer
  71465. * @returns true if everything that can be done was applied
  71466. */
  71467. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71468. }
  71469. /**
  71470. * Defines an optimization used to turn render targets off
  71471. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71472. */
  71473. export class RenderTargetsOptimization extends SceneOptimization {
  71474. /**
  71475. * Gets a string describing the action executed by the current optimization
  71476. * @return description string
  71477. */
  71478. getDescription(): string;
  71479. /**
  71480. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71481. * @param scene defines the current scene where to apply this optimization
  71482. * @param optimizer defines the current optimizer
  71483. * @returns true if everything that can be done was applied
  71484. */
  71485. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71486. }
  71487. /**
  71488. * Defines an optimization used to merge meshes with compatible materials
  71489. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71490. */
  71491. export class MergeMeshesOptimization extends SceneOptimization {
  71492. private static _UpdateSelectionTree;
  71493. /**
  71494. * Gets or sets a boolean which defines if optimization octree has to be updated
  71495. */
  71496. static get UpdateSelectionTree(): boolean;
  71497. /**
  71498. * Gets or sets a boolean which defines if optimization octree has to be updated
  71499. */
  71500. static set UpdateSelectionTree(value: boolean);
  71501. /**
  71502. * Gets a string describing the action executed by the current optimization
  71503. * @return description string
  71504. */
  71505. getDescription(): string;
  71506. private _canBeMerged;
  71507. /**
  71508. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71509. * @param scene defines the current scene where to apply this optimization
  71510. * @param optimizer defines the current optimizer
  71511. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71512. * @returns true if everything that can be done was applied
  71513. */
  71514. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71515. }
  71516. /**
  71517. * Defines a list of options used by SceneOptimizer
  71518. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71519. */
  71520. export class SceneOptimizerOptions {
  71521. /**
  71522. * Defines the target frame rate to reach (60 by default)
  71523. */
  71524. targetFrameRate: number;
  71525. /**
  71526. * Defines the interval between two checkes (2000ms by default)
  71527. */
  71528. trackerDuration: number;
  71529. /**
  71530. * Gets the list of optimizations to apply
  71531. */
  71532. optimizations: SceneOptimization[];
  71533. /**
  71534. * Creates a new list of options used by SceneOptimizer
  71535. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71536. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71537. */
  71538. constructor(
  71539. /**
  71540. * Defines the target frame rate to reach (60 by default)
  71541. */
  71542. targetFrameRate?: number,
  71543. /**
  71544. * Defines the interval between two checkes (2000ms by default)
  71545. */
  71546. trackerDuration?: number);
  71547. /**
  71548. * Add a new optimization
  71549. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71550. * @returns the current SceneOptimizerOptions
  71551. */
  71552. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71553. /**
  71554. * Add a new custom optimization
  71555. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71556. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71557. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71558. * @returns the current SceneOptimizerOptions
  71559. */
  71560. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71561. /**
  71562. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71563. * @param targetFrameRate defines the target frame rate (60 by default)
  71564. * @returns a SceneOptimizerOptions object
  71565. */
  71566. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71567. /**
  71568. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71569. * @param targetFrameRate defines the target frame rate (60 by default)
  71570. * @returns a SceneOptimizerOptions object
  71571. */
  71572. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71573. /**
  71574. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71575. * @param targetFrameRate defines the target frame rate (60 by default)
  71576. * @returns a SceneOptimizerOptions object
  71577. */
  71578. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71579. }
  71580. /**
  71581. * Class used to run optimizations in order to reach a target frame rate
  71582. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71583. */
  71584. export class SceneOptimizer implements IDisposable {
  71585. private _isRunning;
  71586. private _options;
  71587. private _scene;
  71588. private _currentPriorityLevel;
  71589. private _targetFrameRate;
  71590. private _trackerDuration;
  71591. private _currentFrameRate;
  71592. private _sceneDisposeObserver;
  71593. private _improvementMode;
  71594. /**
  71595. * Defines an observable called when the optimizer reaches the target frame rate
  71596. */
  71597. onSuccessObservable: Observable<SceneOptimizer>;
  71598. /**
  71599. * Defines an observable called when the optimizer enables an optimization
  71600. */
  71601. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71602. /**
  71603. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71604. */
  71605. onFailureObservable: Observable<SceneOptimizer>;
  71606. /**
  71607. * Gets a boolean indicating if the optimizer is in improvement mode
  71608. */
  71609. get isInImprovementMode(): boolean;
  71610. /**
  71611. * Gets the current priority level (0 at start)
  71612. */
  71613. get currentPriorityLevel(): number;
  71614. /**
  71615. * Gets the current frame rate checked by the SceneOptimizer
  71616. */
  71617. get currentFrameRate(): number;
  71618. /**
  71619. * Gets or sets the current target frame rate (60 by default)
  71620. */
  71621. get targetFrameRate(): number;
  71622. /**
  71623. * Gets or sets the current target frame rate (60 by default)
  71624. */
  71625. set targetFrameRate(value: number);
  71626. /**
  71627. * Gets or sets the current interval between two checks (every 2000ms by default)
  71628. */
  71629. get trackerDuration(): number;
  71630. /**
  71631. * Gets or sets the current interval between two checks (every 2000ms by default)
  71632. */
  71633. set trackerDuration(value: number);
  71634. /**
  71635. * Gets the list of active optimizations
  71636. */
  71637. get optimizations(): SceneOptimization[];
  71638. /**
  71639. * Creates a new SceneOptimizer
  71640. * @param scene defines the scene to work on
  71641. * @param options defines the options to use with the SceneOptimizer
  71642. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71643. * @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)
  71644. */
  71645. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71646. /**
  71647. * Stops the current optimizer
  71648. */
  71649. stop(): void;
  71650. /**
  71651. * Reset the optimizer to initial step (current priority level = 0)
  71652. */
  71653. reset(): void;
  71654. /**
  71655. * Start the optimizer. By default it will try to reach a specific framerate
  71656. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71657. */
  71658. start(): void;
  71659. private _checkCurrentState;
  71660. /**
  71661. * Release all resources
  71662. */
  71663. dispose(): void;
  71664. /**
  71665. * Helper function to create a SceneOptimizer with one single line of code
  71666. * @param scene defines the scene to work on
  71667. * @param options defines the options to use with the SceneOptimizer
  71668. * @param onSuccess defines a callback to call on success
  71669. * @param onFailure defines a callback to call on failure
  71670. * @returns the new SceneOptimizer object
  71671. */
  71672. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71673. }
  71674. }
  71675. declare module BABYLON {
  71676. /**
  71677. * Class used to serialize a scene into a string
  71678. */
  71679. export class SceneSerializer {
  71680. /**
  71681. * Clear cache used by a previous serialization
  71682. */
  71683. static ClearCache(): void;
  71684. /**
  71685. * Serialize a scene into a JSON compatible object
  71686. * @param scene defines the scene to serialize
  71687. * @returns a JSON compatible object
  71688. */
  71689. static Serialize(scene: Scene): any;
  71690. /**
  71691. * Serialize a mesh into a JSON compatible object
  71692. * @param toSerialize defines the mesh to serialize
  71693. * @param withParents defines if parents must be serialized as well
  71694. * @param withChildren defines if children must be serialized as well
  71695. * @returns a JSON compatible object
  71696. */
  71697. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  71698. }
  71699. }
  71700. declare module BABYLON {
  71701. /**
  71702. * Class used to host texture specific utilities
  71703. */
  71704. export class TextureTools {
  71705. /**
  71706. * Uses the GPU to create a copy texture rescaled at a given size
  71707. * @param texture Texture to copy from
  71708. * @param width defines the desired width
  71709. * @param height defines the desired height
  71710. * @param useBilinearMode defines if bilinear mode has to be used
  71711. * @return the generated texture
  71712. */
  71713. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  71714. }
  71715. }
  71716. declare module BABYLON {
  71717. /**
  71718. * This represents the different options available for the video capture.
  71719. */
  71720. export interface VideoRecorderOptions {
  71721. /** Defines the mime type of the video. */
  71722. mimeType: string;
  71723. /** Defines the FPS the video should be recorded at. */
  71724. fps: number;
  71725. /** Defines the chunk size for the recording data. */
  71726. recordChunckSize: number;
  71727. /** The audio tracks to attach to the recording. */
  71728. audioTracks?: MediaStreamTrack[];
  71729. }
  71730. /**
  71731. * This can help with recording videos from BabylonJS.
  71732. * This is based on the available WebRTC functionalities of the browser.
  71733. *
  71734. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  71735. */
  71736. export class VideoRecorder {
  71737. private static readonly _defaultOptions;
  71738. /**
  71739. * Returns whether or not the VideoRecorder is available in your browser.
  71740. * @param engine Defines the Babylon Engine.
  71741. * @returns true if supported otherwise false.
  71742. */
  71743. static IsSupported(engine: Engine): boolean;
  71744. private readonly _options;
  71745. private _canvas;
  71746. private _mediaRecorder;
  71747. private _recordedChunks;
  71748. private _fileName;
  71749. private _resolve;
  71750. private _reject;
  71751. /**
  71752. * True when a recording is already in progress.
  71753. */
  71754. get isRecording(): boolean;
  71755. /**
  71756. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  71757. * @param engine Defines the BabylonJS Engine you wish to record.
  71758. * @param options Defines options that can be used to customize the capture.
  71759. */
  71760. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  71761. /**
  71762. * Stops the current recording before the default capture timeout passed in the startRecording function.
  71763. */
  71764. stopRecording(): void;
  71765. /**
  71766. * Starts recording the canvas for a max duration specified in parameters.
  71767. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  71768. * If null no automatic download will start and you can rely on the promise to get the data back.
  71769. * @param maxDuration Defines the maximum recording time in seconds.
  71770. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  71771. * @return A promise callback at the end of the recording with the video data in Blob.
  71772. */
  71773. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  71774. /**
  71775. * Releases internal resources used during the recording.
  71776. */
  71777. dispose(): void;
  71778. private _handleDataAvailable;
  71779. private _handleError;
  71780. private _handleStop;
  71781. }
  71782. }
  71783. declare module BABYLON {
  71784. /**
  71785. * Class containing a set of static utilities functions for screenshots
  71786. */
  71787. export class ScreenshotTools {
  71788. /**
  71789. * Captures a screenshot of the current rendering
  71790. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71791. * @param engine defines the rendering engine
  71792. * @param camera defines the source camera
  71793. * @param size This parameter can be set to a single number or to an object with the
  71794. * following (optional) properties: precision, width, height. If a single number is passed,
  71795. * it will be used for both width and height. If an object is passed, the screenshot size
  71796. * will be derived from the parameters. The precision property is a multiplier allowing
  71797. * rendering at a higher or lower resolution
  71798. * @param successCallback defines the callback receives a single parameter which contains the
  71799. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71800. * src parameter of an <img> to display it
  71801. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71802. * Check your browser for supported MIME types
  71803. */
  71804. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  71805. /**
  71806. * Captures a screenshot of the current rendering
  71807. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71808. * @param engine defines the rendering engine
  71809. * @param camera defines the source camera
  71810. * @param size This parameter can be set to a single number or to an object with the
  71811. * following (optional) properties: precision, width, height. If a single number is passed,
  71812. * it will be used for both width and height. If an object is passed, the screenshot size
  71813. * will be derived from the parameters. The precision property is a multiplier allowing
  71814. * rendering at a higher or lower resolution
  71815. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71816. * Check your browser for supported MIME types
  71817. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71818. * to the src parameter of an <img> to display it
  71819. */
  71820. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  71821. /**
  71822. * Generates an image screenshot from the specified camera.
  71823. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71824. * @param engine The engine to use for rendering
  71825. * @param camera The camera to use for rendering
  71826. * @param size This parameter can be set to a single number or to an object with the
  71827. * following (optional) properties: precision, width, height. If a single number is passed,
  71828. * it will be used for both width and height. If an object is passed, the screenshot size
  71829. * will be derived from the parameters. The precision property is a multiplier allowing
  71830. * rendering at a higher or lower resolution
  71831. * @param successCallback The callback receives a single parameter which contains the
  71832. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71833. * src parameter of an <img> to display it
  71834. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71835. * Check your browser for supported MIME types
  71836. * @param samples Texture samples (default: 1)
  71837. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71838. * @param fileName A name for for the downloaded file.
  71839. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71840. */
  71841. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  71842. /**
  71843. * Generates an image screenshot from the specified camera.
  71844. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71845. * @param engine The engine to use for rendering
  71846. * @param camera The camera to use for rendering
  71847. * @param size This parameter can be set to a single number or to an object with the
  71848. * following (optional) properties: precision, width, height. If a single number is passed,
  71849. * it will be used for both width and height. If an object is passed, the screenshot size
  71850. * will be derived from the parameters. The precision property is a multiplier allowing
  71851. * rendering at a higher or lower resolution
  71852. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71853. * Check your browser for supported MIME types
  71854. * @param samples Texture samples (default: 1)
  71855. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71856. * @param fileName A name for for the downloaded file.
  71857. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71858. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71859. * to the src parameter of an <img> to display it
  71860. */
  71861. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  71862. /**
  71863. * Gets height and width for screenshot size
  71864. * @private
  71865. */
  71866. private static _getScreenshotSize;
  71867. }
  71868. }
  71869. declare module BABYLON {
  71870. /**
  71871. * Interface for a data buffer
  71872. */
  71873. export interface IDataBuffer {
  71874. /**
  71875. * Reads bytes from the data buffer.
  71876. * @param byteOffset The byte offset to read
  71877. * @param byteLength The byte length to read
  71878. * @returns A promise that resolves when the bytes are read
  71879. */
  71880. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  71881. /**
  71882. * The byte length of the buffer.
  71883. */
  71884. readonly byteLength: number;
  71885. }
  71886. /**
  71887. * Utility class for reading from a data buffer
  71888. */
  71889. export class DataReader {
  71890. /**
  71891. * The data buffer associated with this data reader.
  71892. */
  71893. readonly buffer: IDataBuffer;
  71894. /**
  71895. * The current byte offset from the beginning of the data buffer.
  71896. */
  71897. byteOffset: number;
  71898. private _dataView;
  71899. private _dataByteOffset;
  71900. /**
  71901. * Constructor
  71902. * @param buffer The buffer to read
  71903. */
  71904. constructor(buffer: IDataBuffer);
  71905. /**
  71906. * Loads the given byte length.
  71907. * @param byteLength The byte length to load
  71908. * @returns A promise that resolves when the load is complete
  71909. */
  71910. loadAsync(byteLength: number): Promise<void>;
  71911. /**
  71912. * Read a unsigned 32-bit integer from the currently loaded data range.
  71913. * @returns The 32-bit integer read
  71914. */
  71915. readUint32(): number;
  71916. /**
  71917. * Read a byte array from the currently loaded data range.
  71918. * @param byteLength The byte length to read
  71919. * @returns The byte array read
  71920. */
  71921. readUint8Array(byteLength: number): Uint8Array;
  71922. /**
  71923. * Read a string from the currently loaded data range.
  71924. * @param byteLength The byte length to read
  71925. * @returns The string read
  71926. */
  71927. readString(byteLength: number): string;
  71928. /**
  71929. * Skips the given byte length the currently loaded data range.
  71930. * @param byteLength The byte length to skip
  71931. */
  71932. skipBytes(byteLength: number): void;
  71933. }
  71934. }
  71935. declare module BABYLON {
  71936. /**
  71937. * Class for storing data to local storage if available or in-memory storage otherwise
  71938. */
  71939. export class DataStorage {
  71940. private static _Storage;
  71941. private static _GetStorage;
  71942. /**
  71943. * Reads a string from the data storage
  71944. * @param key The key to read
  71945. * @param defaultValue The value if the key doesn't exist
  71946. * @returns The string value
  71947. */
  71948. static ReadString(key: string, defaultValue: string): string;
  71949. /**
  71950. * Writes a string to the data storage
  71951. * @param key The key to write
  71952. * @param value The value to write
  71953. */
  71954. static WriteString(key: string, value: string): void;
  71955. /**
  71956. * Reads a boolean from the data storage
  71957. * @param key The key to read
  71958. * @param defaultValue The value if the key doesn't exist
  71959. * @returns The boolean value
  71960. */
  71961. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  71962. /**
  71963. * Writes a boolean to the data storage
  71964. * @param key The key to write
  71965. * @param value The value to write
  71966. */
  71967. static WriteBoolean(key: string, value: boolean): void;
  71968. /**
  71969. * Reads a number from the data storage
  71970. * @param key The key to read
  71971. * @param defaultValue The value if the key doesn't exist
  71972. * @returns The number value
  71973. */
  71974. static ReadNumber(key: string, defaultValue: number): number;
  71975. /**
  71976. * Writes a number to the data storage
  71977. * @param key The key to write
  71978. * @param value The value to write
  71979. */
  71980. static WriteNumber(key: string, value: number): void;
  71981. }
  71982. }
  71983. declare module BABYLON {
  71984. /**
  71985. * Options used for hit testing
  71986. */
  71987. export interface IWebXRLegacyHitTestOptions {
  71988. /**
  71989. * Only test when user interacted with the scene. Default - hit test every frame
  71990. */
  71991. testOnPointerDownOnly?: boolean;
  71992. /**
  71993. * The node to use to transform the local results to world coordinates
  71994. */
  71995. worldParentNode?: TransformNode;
  71996. }
  71997. /**
  71998. * Interface defining the babylon result of raycasting/hit-test
  71999. */
  72000. export interface IWebXRLegacyHitResult {
  72001. /**
  72002. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72003. */
  72004. transformationMatrix: Matrix;
  72005. /**
  72006. * The native hit test result
  72007. */
  72008. xrHitResult: XRHitResult | XRHitTestResult;
  72009. }
  72010. /**
  72011. * The currently-working hit-test module.
  72012. * Hit test (or Ray-casting) is used to interact with the real world.
  72013. * For further information read here - https://github.com/immersive-web/hit-test
  72014. */
  72015. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72016. /**
  72017. * options to use when constructing this feature
  72018. */
  72019. readonly options: IWebXRLegacyHitTestOptions;
  72020. private _direction;
  72021. private _mat;
  72022. private _onSelectEnabled;
  72023. private _origin;
  72024. /**
  72025. * The module's name
  72026. */
  72027. static readonly Name: string;
  72028. /**
  72029. * The (Babylon) version of this module.
  72030. * This is an integer representing the implementation version.
  72031. * This number does not correspond to the WebXR specs version
  72032. */
  72033. static readonly Version: number;
  72034. /**
  72035. * Populated with the last native XR Hit Results
  72036. */
  72037. lastNativeXRHitResults: XRHitResult[];
  72038. /**
  72039. * Triggered when new babylon (transformed) hit test results are available
  72040. */
  72041. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72042. /**
  72043. * Creates a new instance of the (legacy version) hit test feature
  72044. * @param _xrSessionManager an instance of WebXRSessionManager
  72045. * @param options options to use when constructing this feature
  72046. */
  72047. constructor(_xrSessionManager: WebXRSessionManager,
  72048. /**
  72049. * options to use when constructing this feature
  72050. */
  72051. options?: IWebXRLegacyHitTestOptions);
  72052. /**
  72053. * execute a hit test with an XR Ray
  72054. *
  72055. * @param xrSession a native xrSession that will execute this hit test
  72056. * @param xrRay the ray (position and direction) to use for ray-casting
  72057. * @param referenceSpace native XR reference space to use for the hit-test
  72058. * @param filter filter function that will filter the results
  72059. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72060. */
  72061. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72062. /**
  72063. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72064. * @param event the (select) event to use to select with
  72065. * @param referenceSpace the reference space to use for this hit test
  72066. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72067. */
  72068. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72069. /**
  72070. * attach this feature
  72071. * Will usually be called by the features manager
  72072. *
  72073. * @returns true if successful.
  72074. */
  72075. attach(): boolean;
  72076. /**
  72077. * detach this feature.
  72078. * Will usually be called by the features manager
  72079. *
  72080. * @returns true if successful.
  72081. */
  72082. detach(): boolean;
  72083. /**
  72084. * Dispose this feature and all of the resources attached
  72085. */
  72086. dispose(): void;
  72087. protected _onXRFrame(frame: XRFrame): void;
  72088. private _onHitTestResults;
  72089. private _onSelect;
  72090. }
  72091. }
  72092. declare module BABYLON {
  72093. /**
  72094. * Options used in the plane detector module
  72095. */
  72096. export interface IWebXRPlaneDetectorOptions {
  72097. /**
  72098. * The node to use to transform the local results to world coordinates
  72099. */
  72100. worldParentNode?: TransformNode;
  72101. }
  72102. /**
  72103. * A babylon interface for a WebXR plane.
  72104. * A Plane is actually a polygon, built from N points in space
  72105. *
  72106. * Supported in chrome 79, not supported in canary 81 ATM
  72107. */
  72108. export interface IWebXRPlane {
  72109. /**
  72110. * a babylon-assigned ID for this polygon
  72111. */
  72112. id: number;
  72113. /**
  72114. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72115. */
  72116. polygonDefinition: Array<Vector3>;
  72117. /**
  72118. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72119. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72120. */
  72121. transformationMatrix: Matrix;
  72122. /**
  72123. * the native xr-plane object
  72124. */
  72125. xrPlane: XRPlane;
  72126. }
  72127. /**
  72128. * The plane detector is used to detect planes in the real world when in AR
  72129. * For more information see https://github.com/immersive-web/real-world-geometry/
  72130. */
  72131. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72132. private _options;
  72133. private _detectedPlanes;
  72134. private _enabled;
  72135. private _lastFrameDetected;
  72136. /**
  72137. * The module's name
  72138. */
  72139. static readonly Name: string;
  72140. /**
  72141. * The (Babylon) version of this module.
  72142. * This is an integer representing the implementation version.
  72143. * This number does not correspond to the WebXR specs version
  72144. */
  72145. static readonly Version: number;
  72146. /**
  72147. * Observers registered here will be executed when a new plane was added to the session
  72148. */
  72149. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72150. /**
  72151. * Observers registered here will be executed when a plane is no longer detected in the session
  72152. */
  72153. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72154. /**
  72155. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72156. * This can execute N times every frame
  72157. */
  72158. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72159. /**
  72160. * construct a new Plane Detector
  72161. * @param _xrSessionManager an instance of xr Session manager
  72162. * @param _options configuration to use when constructing this feature
  72163. */
  72164. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72165. /**
  72166. * Dispose this feature and all of the resources attached
  72167. */
  72168. dispose(): void;
  72169. protected _onXRFrame(frame: XRFrame): void;
  72170. private _init;
  72171. private _updatePlaneWithXRPlane;
  72172. /**
  72173. * avoiding using Array.find for global support.
  72174. * @param xrPlane the plane to find in the array
  72175. */
  72176. private findIndexInPlaneArray;
  72177. }
  72178. }
  72179. declare module BABYLON {
  72180. /**
  72181. * Configuration options of the anchor system
  72182. */
  72183. export interface IWebXRAnchorSystemOptions {
  72184. /**
  72185. * Should a new anchor be added every time a select event is triggered
  72186. */
  72187. addAnchorOnSelect?: boolean;
  72188. /**
  72189. * should the anchor system use plane detection.
  72190. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72191. */
  72192. usePlaneDetection?: boolean;
  72193. /**
  72194. * a node that will be used to convert local to world coordinates
  72195. */
  72196. worldParentNode?: TransformNode;
  72197. }
  72198. /**
  72199. * A babylon container for an XR Anchor
  72200. */
  72201. export interface IWebXRAnchor {
  72202. /**
  72203. * A babylon-assigned ID for this anchor
  72204. */
  72205. id: number;
  72206. /**
  72207. * Transformation matrix to apply to an object attached to this anchor
  72208. */
  72209. transformationMatrix: Matrix;
  72210. /**
  72211. * The native anchor object
  72212. */
  72213. xrAnchor: XRAnchor;
  72214. }
  72215. /**
  72216. * An implementation of the anchor system of WebXR.
  72217. * Note that the current documented implementation is not available in any browser. Future implementations
  72218. * will use the frame to create an anchor and not the session or a detected plane
  72219. * For further information see https://github.com/immersive-web/anchors/
  72220. */
  72221. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72222. private _options;
  72223. private _enabled;
  72224. private _hitTestModule;
  72225. private _lastFrameDetected;
  72226. private _onSelect;
  72227. private _planeDetector;
  72228. private _trackedAnchors;
  72229. /**
  72230. * The module's name
  72231. */
  72232. static readonly Name: string;
  72233. /**
  72234. * The (Babylon) version of this module.
  72235. * This is an integer representing the implementation version.
  72236. * This number does not correspond to the WebXR specs version
  72237. */
  72238. static readonly Version: number;
  72239. /**
  72240. * Observers registered here will be executed when a new anchor was added to the session
  72241. */
  72242. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72243. /**
  72244. * Observers registered here will be executed when an anchor was removed from the session
  72245. */
  72246. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72247. /**
  72248. * Observers registered here will be executed when an existing anchor updates
  72249. * This can execute N times every frame
  72250. */
  72251. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72252. /**
  72253. * constructs a new anchor system
  72254. * @param _xrSessionManager an instance of WebXRSessionManager
  72255. * @param _options configuration object for this feature
  72256. */
  72257. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72258. /**
  72259. * Add anchor at a specific XR point.
  72260. *
  72261. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72262. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72263. * @returns a promise the fulfills when the anchor was created
  72264. */
  72265. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72266. /**
  72267. * attach this feature
  72268. * Will usually be called by the features manager
  72269. *
  72270. * @returns true if successful.
  72271. */
  72272. attach(): boolean;
  72273. /**
  72274. * detach this feature.
  72275. * Will usually be called by the features manager
  72276. *
  72277. * @returns true if successful.
  72278. */
  72279. detach(): boolean;
  72280. /**
  72281. * Dispose this feature and all of the resources attached
  72282. */
  72283. dispose(): void;
  72284. /**
  72285. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72286. * @param hitTestModule the hit-test module to use.
  72287. */
  72288. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72289. /**
  72290. * set the plane detector to use in order to create anchors from frames
  72291. * @param planeDetector the plane-detector module to use
  72292. * @param enable enable plane-anchors. default is true
  72293. */
  72294. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72295. protected _onXRFrame(frame: XRFrame): void;
  72296. /**
  72297. * avoiding using Array.find for global support.
  72298. * @param xrAnchor the plane to find in the array
  72299. */
  72300. private _findIndexInAnchorArray;
  72301. private _updateAnchorWithXRFrame;
  72302. }
  72303. }
  72304. declare module BABYLON {
  72305. /**
  72306. * Options interface for the background remover plugin
  72307. */
  72308. export interface IWebXRBackgroundRemoverOptions {
  72309. /**
  72310. * Further background meshes to disable when entering AR
  72311. */
  72312. backgroundMeshes?: AbstractMesh[];
  72313. /**
  72314. * flags to configure the removal of the environment helper.
  72315. * If not set, the entire background will be removed. If set, flags should be set as well.
  72316. */
  72317. environmentHelperRemovalFlags?: {
  72318. /**
  72319. * Should the skybox be removed (default false)
  72320. */
  72321. skyBox?: boolean;
  72322. /**
  72323. * Should the ground be removed (default false)
  72324. */
  72325. ground?: boolean;
  72326. };
  72327. /**
  72328. * don't disable the environment helper
  72329. */
  72330. ignoreEnvironmentHelper?: boolean;
  72331. }
  72332. /**
  72333. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72334. */
  72335. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72336. /**
  72337. * read-only options to be used in this module
  72338. */
  72339. readonly options: IWebXRBackgroundRemoverOptions;
  72340. /**
  72341. * The module's name
  72342. */
  72343. static readonly Name: string;
  72344. /**
  72345. * The (Babylon) version of this module.
  72346. * This is an integer representing the implementation version.
  72347. * This number does not correspond to the WebXR specs version
  72348. */
  72349. static readonly Version: number;
  72350. /**
  72351. * registered observers will be triggered when the background state changes
  72352. */
  72353. onBackgroundStateChangedObservable: Observable<boolean>;
  72354. /**
  72355. * constructs a new background remover module
  72356. * @param _xrSessionManager the session manager for this module
  72357. * @param options read-only options to be used in this module
  72358. */
  72359. constructor(_xrSessionManager: WebXRSessionManager,
  72360. /**
  72361. * read-only options to be used in this module
  72362. */
  72363. options?: IWebXRBackgroundRemoverOptions);
  72364. /**
  72365. * attach this feature
  72366. * Will usually be called by the features manager
  72367. *
  72368. * @returns true if successful.
  72369. */
  72370. attach(): boolean;
  72371. /**
  72372. * detach this feature.
  72373. * Will usually be called by the features manager
  72374. *
  72375. * @returns true if successful.
  72376. */
  72377. detach(): boolean;
  72378. /**
  72379. * Dispose this feature and all of the resources attached
  72380. */
  72381. dispose(): void;
  72382. protected _onXRFrame(_xrFrame: XRFrame): void;
  72383. private _setBackgroundState;
  72384. }
  72385. }
  72386. declare module BABYLON {
  72387. /**
  72388. * Options for the controller physics feature
  72389. */
  72390. export class IWebXRControllerPhysicsOptions {
  72391. /**
  72392. * Should the headset get its own impostor
  72393. */
  72394. enableHeadsetImpostor?: boolean;
  72395. /**
  72396. * Optional parameters for the headset impostor
  72397. */
  72398. headsetImpostorParams?: {
  72399. /**
  72400. * The type of impostor to create. Default is sphere
  72401. */
  72402. impostorType: number;
  72403. /**
  72404. * the size of the impostor. Defaults to 10cm
  72405. */
  72406. impostorSize?: number | {
  72407. width: number;
  72408. height: number;
  72409. depth: number;
  72410. };
  72411. /**
  72412. * Friction definitions
  72413. */
  72414. friction?: number;
  72415. /**
  72416. * Restitution
  72417. */
  72418. restitution?: number;
  72419. };
  72420. /**
  72421. * The physics properties of the future impostors
  72422. */
  72423. physicsProperties?: {
  72424. /**
  72425. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72426. * Note that this requires a physics engine that supports mesh impostors!
  72427. */
  72428. useControllerMesh?: boolean;
  72429. /**
  72430. * The type of impostor to create. Default is sphere
  72431. */
  72432. impostorType?: number;
  72433. /**
  72434. * the size of the impostor. Defaults to 10cm
  72435. */
  72436. impostorSize?: number | {
  72437. width: number;
  72438. height: number;
  72439. depth: number;
  72440. };
  72441. /**
  72442. * Friction definitions
  72443. */
  72444. friction?: number;
  72445. /**
  72446. * Restitution
  72447. */
  72448. restitution?: number;
  72449. };
  72450. /**
  72451. * the xr input to use with this pointer selection
  72452. */
  72453. xrInput: WebXRInput;
  72454. }
  72455. /**
  72456. * Add physics impostor to your webxr controllers,
  72457. * including naive calculation of their linear and angular velocity
  72458. */
  72459. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72460. private readonly _options;
  72461. private _attachController;
  72462. private _controllers;
  72463. private _debugMode;
  72464. private _delta;
  72465. private _headsetImpostor?;
  72466. private _headsetMesh?;
  72467. private _lastTimestamp;
  72468. private _tmpQuaternion;
  72469. private _tmpVector;
  72470. /**
  72471. * The module's name
  72472. */
  72473. static readonly Name: string;
  72474. /**
  72475. * The (Babylon) version of this module.
  72476. * This is an integer representing the implementation version.
  72477. * This number does not correspond to the webxr specs version
  72478. */
  72479. static readonly Version: number;
  72480. /**
  72481. * Construct a new Controller Physics Feature
  72482. * @param _xrSessionManager the corresponding xr session manager
  72483. * @param _options options to create this feature with
  72484. */
  72485. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72486. /**
  72487. * @hidden
  72488. * enable debugging - will show console outputs and the impostor mesh
  72489. */
  72490. _enablePhysicsDebug(): void;
  72491. /**
  72492. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72493. * @param xrController the controller to add
  72494. */
  72495. addController(xrController: WebXRInputSource): void;
  72496. /**
  72497. * attach this feature
  72498. * Will usually be called by the features manager
  72499. *
  72500. * @returns true if successful.
  72501. */
  72502. attach(): boolean;
  72503. /**
  72504. * detach this feature.
  72505. * Will usually be called by the features manager
  72506. *
  72507. * @returns true if successful.
  72508. */
  72509. detach(): boolean;
  72510. /**
  72511. * Get the headset impostor, if enabled
  72512. * @returns the impostor
  72513. */
  72514. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72515. /**
  72516. * Get the physics impostor of a specific controller.
  72517. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72518. * @param controller the controller or the controller id of which to get the impostor
  72519. * @returns the impostor or null
  72520. */
  72521. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72522. /**
  72523. * Update the physics properties provided in the constructor
  72524. * @param newProperties the new properties object
  72525. */
  72526. setPhysicsProperties(newProperties: {
  72527. impostorType?: number;
  72528. impostorSize?: number | {
  72529. width: number;
  72530. height: number;
  72531. depth: number;
  72532. };
  72533. friction?: number;
  72534. restitution?: number;
  72535. }): void;
  72536. protected _onXRFrame(_xrFrame: any): void;
  72537. private _detachController;
  72538. }
  72539. }
  72540. declare module BABYLON {
  72541. /**
  72542. * Options used for hit testing (version 2)
  72543. */
  72544. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72545. /**
  72546. * Do not create a permanent hit test. Will usually be used when only
  72547. * transient inputs are needed.
  72548. */
  72549. disablePermanentHitTest?: boolean;
  72550. /**
  72551. * Enable transient (for example touch-based) hit test inspections
  72552. */
  72553. enableTransientHitTest?: boolean;
  72554. /**
  72555. * Offset ray for the permanent hit test
  72556. */
  72557. offsetRay?: Vector3;
  72558. /**
  72559. * Offset ray for the transient hit test
  72560. */
  72561. transientOffsetRay?: Vector3;
  72562. /**
  72563. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72564. */
  72565. useReferenceSpace?: boolean;
  72566. }
  72567. /**
  72568. * Interface defining the babylon result of hit-test
  72569. */
  72570. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72571. /**
  72572. * The input source that generated this hit test (if transient)
  72573. */
  72574. inputSource?: XRInputSource;
  72575. /**
  72576. * Is this a transient hit test
  72577. */
  72578. isTransient?: boolean;
  72579. /**
  72580. * Position of the hit test result
  72581. */
  72582. position: Vector3;
  72583. /**
  72584. * Rotation of the hit test result
  72585. */
  72586. rotationQuaternion: Quaternion;
  72587. }
  72588. /**
  72589. * The currently-working hit-test module.
  72590. * Hit test (or Ray-casting) is used to interact with the real world.
  72591. * For further information read here - https://github.com/immersive-web/hit-test
  72592. *
  72593. * Tested on chrome (mobile) 80.
  72594. */
  72595. export class WebXRHitTest extends WebXRAbstractFeature {
  72596. /**
  72597. * options to use when constructing this feature
  72598. */
  72599. readonly options: IWebXRHitTestOptions;
  72600. private _tmpMat;
  72601. private _tmpPos;
  72602. private _tmpQuat;
  72603. private _transientXrHitTestSource;
  72604. private _xrHitTestSource;
  72605. private initHitTestSource;
  72606. /**
  72607. * The module's name
  72608. */
  72609. static readonly Name: string;
  72610. /**
  72611. * The (Babylon) version of this module.
  72612. * This is an integer representing the implementation version.
  72613. * This number does not correspond to the WebXR specs version
  72614. */
  72615. static readonly Version: number;
  72616. /**
  72617. * When set to true, each hit test will have its own position/rotation objects
  72618. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72619. * the developers will clone them or copy them as they see fit.
  72620. */
  72621. autoCloneTransformation: boolean;
  72622. /**
  72623. * Populated with the last native XR Hit Results
  72624. */
  72625. lastNativeXRHitResults: XRHitResult[];
  72626. /**
  72627. * Triggered when new babylon (transformed) hit test results are available
  72628. */
  72629. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72630. /**
  72631. * Use this to temporarily pause hit test checks.
  72632. */
  72633. paused: boolean;
  72634. /**
  72635. * Creates a new instance of the hit test feature
  72636. * @param _xrSessionManager an instance of WebXRSessionManager
  72637. * @param options options to use when constructing this feature
  72638. */
  72639. constructor(_xrSessionManager: WebXRSessionManager,
  72640. /**
  72641. * options to use when constructing this feature
  72642. */
  72643. options?: IWebXRHitTestOptions);
  72644. /**
  72645. * attach this feature
  72646. * Will usually be called by the features manager
  72647. *
  72648. * @returns true if successful.
  72649. */
  72650. attach(): boolean;
  72651. /**
  72652. * detach this feature.
  72653. * Will usually be called by the features manager
  72654. *
  72655. * @returns true if successful.
  72656. */
  72657. detach(): boolean;
  72658. /**
  72659. * Dispose this feature and all of the resources attached
  72660. */
  72661. dispose(): void;
  72662. protected _onXRFrame(frame: XRFrame): void;
  72663. private _processWebXRHitTestResult;
  72664. }
  72665. }
  72666. declare module BABYLON {
  72667. /**
  72668. * The motion controller class for all microsoft mixed reality controllers
  72669. */
  72670. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72671. protected readonly _mapping: {
  72672. defaultButton: {
  72673. valueNodeName: string;
  72674. unpressedNodeName: string;
  72675. pressedNodeName: string;
  72676. };
  72677. defaultAxis: {
  72678. valueNodeName: string;
  72679. minNodeName: string;
  72680. maxNodeName: string;
  72681. };
  72682. buttons: {
  72683. "xr-standard-trigger": {
  72684. rootNodeName: string;
  72685. componentProperty: string;
  72686. states: string[];
  72687. };
  72688. "xr-standard-squeeze": {
  72689. rootNodeName: string;
  72690. componentProperty: string;
  72691. states: string[];
  72692. };
  72693. "xr-standard-touchpad": {
  72694. rootNodeName: string;
  72695. labelAnchorNodeName: string;
  72696. touchPointNodeName: string;
  72697. };
  72698. "xr-standard-thumbstick": {
  72699. rootNodeName: string;
  72700. componentProperty: string;
  72701. states: string[];
  72702. };
  72703. };
  72704. axes: {
  72705. "xr-standard-touchpad": {
  72706. "x-axis": {
  72707. rootNodeName: string;
  72708. };
  72709. "y-axis": {
  72710. rootNodeName: string;
  72711. };
  72712. };
  72713. "xr-standard-thumbstick": {
  72714. "x-axis": {
  72715. rootNodeName: string;
  72716. };
  72717. "y-axis": {
  72718. rootNodeName: string;
  72719. };
  72720. };
  72721. };
  72722. };
  72723. /**
  72724. * The base url used to load the left and right controller models
  72725. */
  72726. static MODEL_BASE_URL: string;
  72727. /**
  72728. * The name of the left controller model file
  72729. */
  72730. static MODEL_LEFT_FILENAME: string;
  72731. /**
  72732. * The name of the right controller model file
  72733. */
  72734. static MODEL_RIGHT_FILENAME: string;
  72735. profileId: string;
  72736. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72737. protected _getFilenameAndPath(): {
  72738. filename: string;
  72739. path: string;
  72740. };
  72741. protected _getModelLoadingConstraints(): boolean;
  72742. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72743. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72744. protected _updateModel(): void;
  72745. }
  72746. }
  72747. declare module BABYLON {
  72748. /**
  72749. * The motion controller class for oculus touch (quest, rift).
  72750. * This class supports legacy mapping as well the standard xr mapping
  72751. */
  72752. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72753. private _forceLegacyControllers;
  72754. private _modelRootNode;
  72755. /**
  72756. * The base url used to load the left and right controller models
  72757. */
  72758. static MODEL_BASE_URL: string;
  72759. /**
  72760. * The name of the left controller model file
  72761. */
  72762. static MODEL_LEFT_FILENAME: string;
  72763. /**
  72764. * The name of the right controller model file
  72765. */
  72766. static MODEL_RIGHT_FILENAME: string;
  72767. /**
  72768. * Base Url for the Quest controller model.
  72769. */
  72770. static QUEST_MODEL_BASE_URL: string;
  72771. profileId: string;
  72772. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  72773. protected _getFilenameAndPath(): {
  72774. filename: string;
  72775. path: string;
  72776. };
  72777. protected _getModelLoadingConstraints(): boolean;
  72778. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72779. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72780. protected _updateModel(): void;
  72781. /**
  72782. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  72783. * between the touch and touch 2.
  72784. */
  72785. private _isQuest;
  72786. }
  72787. }
  72788. declare module BABYLON {
  72789. /**
  72790. * The motion controller class for the standard HTC-Vive controllers
  72791. */
  72792. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  72793. private _modelRootNode;
  72794. /**
  72795. * The base url used to load the left and right controller models
  72796. */
  72797. static MODEL_BASE_URL: string;
  72798. /**
  72799. * File name for the controller model.
  72800. */
  72801. static MODEL_FILENAME: string;
  72802. profileId: string;
  72803. /**
  72804. * Create a new Vive motion controller object
  72805. * @param scene the scene to use to create this controller
  72806. * @param gamepadObject the corresponding gamepad object
  72807. * @param handedness the handedness of the controller
  72808. */
  72809. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72810. protected _getFilenameAndPath(): {
  72811. filename: string;
  72812. path: string;
  72813. };
  72814. protected _getModelLoadingConstraints(): boolean;
  72815. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72816. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72817. protected _updateModel(): void;
  72818. }
  72819. }
  72820. declare module BABYLON {
  72821. /**
  72822. * A cursor which tracks a point on a path
  72823. */
  72824. export class PathCursor {
  72825. private path;
  72826. /**
  72827. * Stores path cursor callbacks for when an onchange event is triggered
  72828. */
  72829. private _onchange;
  72830. /**
  72831. * The value of the path cursor
  72832. */
  72833. value: number;
  72834. /**
  72835. * The animation array of the path cursor
  72836. */
  72837. animations: Animation[];
  72838. /**
  72839. * Initializes the path cursor
  72840. * @param path The path to track
  72841. */
  72842. constructor(path: Path2);
  72843. /**
  72844. * Gets the cursor point on the path
  72845. * @returns A point on the path cursor at the cursor location
  72846. */
  72847. getPoint(): Vector3;
  72848. /**
  72849. * Moves the cursor ahead by the step amount
  72850. * @param step The amount to move the cursor forward
  72851. * @returns This path cursor
  72852. */
  72853. moveAhead(step?: number): PathCursor;
  72854. /**
  72855. * Moves the cursor behind by the step amount
  72856. * @param step The amount to move the cursor back
  72857. * @returns This path cursor
  72858. */
  72859. moveBack(step?: number): PathCursor;
  72860. /**
  72861. * Moves the cursor by the step amount
  72862. * If the step amount is greater than one, an exception is thrown
  72863. * @param step The amount to move the cursor
  72864. * @returns This path cursor
  72865. */
  72866. move(step: number): PathCursor;
  72867. /**
  72868. * Ensures that the value is limited between zero and one
  72869. * @returns This path cursor
  72870. */
  72871. private ensureLimits;
  72872. /**
  72873. * Runs onchange callbacks on change (used by the animation engine)
  72874. * @returns This path cursor
  72875. */
  72876. private raiseOnChange;
  72877. /**
  72878. * Executes a function on change
  72879. * @param f A path cursor onchange callback
  72880. * @returns This path cursor
  72881. */
  72882. onchange(f: (cursor: PathCursor) => void): PathCursor;
  72883. }
  72884. }
  72885. declare module BABYLON {
  72886. /** @hidden */
  72887. export var blurPixelShader: {
  72888. name: string;
  72889. shader: string;
  72890. };
  72891. }
  72892. declare module BABYLON {
  72893. /** @hidden */
  72894. export var pointCloudVertexDeclaration: {
  72895. name: string;
  72896. shader: string;
  72897. };
  72898. }
  72899. // Mixins
  72900. interface Window {
  72901. mozIndexedDB: IDBFactory;
  72902. webkitIndexedDB: IDBFactory;
  72903. msIndexedDB: IDBFactory;
  72904. webkitURL: typeof URL;
  72905. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  72906. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  72907. WebGLRenderingContext: WebGLRenderingContext;
  72908. MSGesture: MSGesture;
  72909. CANNON: any;
  72910. AudioContext: AudioContext;
  72911. webkitAudioContext: AudioContext;
  72912. PointerEvent: any;
  72913. Math: Math;
  72914. Uint8Array: Uint8ArrayConstructor;
  72915. Float32Array: Float32ArrayConstructor;
  72916. mozURL: typeof URL;
  72917. msURL: typeof URL;
  72918. VRFrameData: any; // WebVR, from specs 1.1
  72919. DracoDecoderModule: any;
  72920. setImmediate(handler: (...args: any[]) => void): number;
  72921. }
  72922. interface HTMLCanvasElement {
  72923. requestPointerLock(): void;
  72924. msRequestPointerLock?(): void;
  72925. mozRequestPointerLock?(): void;
  72926. webkitRequestPointerLock?(): void;
  72927. /** Track wether a record is in progress */
  72928. isRecording: boolean;
  72929. /** Capture Stream method defined by some browsers */
  72930. captureStream(fps?: number): MediaStream;
  72931. }
  72932. interface CanvasRenderingContext2D {
  72933. msImageSmoothingEnabled: boolean;
  72934. }
  72935. interface MouseEvent {
  72936. mozMovementX: number;
  72937. mozMovementY: number;
  72938. webkitMovementX: number;
  72939. webkitMovementY: number;
  72940. msMovementX: number;
  72941. msMovementY: number;
  72942. }
  72943. interface Navigator {
  72944. mozGetVRDevices: (any: any) => any;
  72945. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72946. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72947. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72948. webkitGetGamepads(): Gamepad[];
  72949. msGetGamepads(): Gamepad[];
  72950. webkitGamepads(): Gamepad[];
  72951. }
  72952. interface HTMLVideoElement {
  72953. mozSrcObject: any;
  72954. }
  72955. interface Math {
  72956. fround(x: number): number;
  72957. imul(a: number, b: number): number;
  72958. }
  72959. interface WebGLRenderingContext {
  72960. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  72961. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  72962. vertexAttribDivisor(index: number, divisor: number): void;
  72963. createVertexArray(): any;
  72964. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  72965. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  72966. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  72967. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  72968. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  72969. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  72970. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  72971. // Queries
  72972. createQuery(): WebGLQuery;
  72973. deleteQuery(query: WebGLQuery): void;
  72974. beginQuery(target: number, query: WebGLQuery): void;
  72975. endQuery(target: number): void;
  72976. getQueryParameter(query: WebGLQuery, pname: number): any;
  72977. getQuery(target: number, pname: number): any;
  72978. MAX_SAMPLES: number;
  72979. RGBA8: number;
  72980. READ_FRAMEBUFFER: number;
  72981. DRAW_FRAMEBUFFER: number;
  72982. UNIFORM_BUFFER: number;
  72983. HALF_FLOAT_OES: number;
  72984. RGBA16F: number;
  72985. RGBA32F: number;
  72986. R32F: number;
  72987. RG32F: number;
  72988. RGB32F: number;
  72989. R16F: number;
  72990. RG16F: number;
  72991. RGB16F: number;
  72992. RED: number;
  72993. RG: number;
  72994. R8: number;
  72995. RG8: number;
  72996. UNSIGNED_INT_24_8: number;
  72997. DEPTH24_STENCIL8: number;
  72998. MIN: number;
  72999. MAX: number;
  73000. /* Multiple Render Targets */
  73001. drawBuffers(buffers: number[]): void;
  73002. readBuffer(src: number): void;
  73003. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  73004. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  73005. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  73006. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  73007. // Occlusion Query
  73008. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73009. ANY_SAMPLES_PASSED: number;
  73010. QUERY_RESULT_AVAILABLE: number;
  73011. QUERY_RESULT: number;
  73012. }
  73013. interface WebGLProgram {
  73014. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73015. }
  73016. interface EXT_disjoint_timer_query {
  73017. QUERY_COUNTER_BITS_EXT: number;
  73018. TIME_ELAPSED_EXT: number;
  73019. TIMESTAMP_EXT: number;
  73020. GPU_DISJOINT_EXT: number;
  73021. QUERY_RESULT_EXT: number;
  73022. QUERY_RESULT_AVAILABLE_EXT: number;
  73023. queryCounterEXT(query: WebGLQuery, target: number): void;
  73024. createQueryEXT(): WebGLQuery;
  73025. beginQueryEXT(target: number, query: WebGLQuery): void;
  73026. endQueryEXT(target: number): void;
  73027. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73028. deleteQueryEXT(query: WebGLQuery): void;
  73029. }
  73030. interface WebGLUniformLocation {
  73031. _currentState: any;
  73032. }
  73033. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73034. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73035. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73036. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73037. interface WebGLRenderingContext {
  73038. readonly RASTERIZER_DISCARD: number;
  73039. readonly DEPTH_COMPONENT24: number;
  73040. readonly TEXTURE_3D: number;
  73041. readonly TEXTURE_2D_ARRAY: number;
  73042. readonly TEXTURE_COMPARE_FUNC: number;
  73043. readonly TEXTURE_COMPARE_MODE: number;
  73044. readonly COMPARE_REF_TO_TEXTURE: number;
  73045. readonly TEXTURE_WRAP_R: number;
  73046. readonly HALF_FLOAT: number;
  73047. readonly RGB8: number;
  73048. readonly RED_INTEGER: number;
  73049. readonly RG_INTEGER: number;
  73050. readonly RGB_INTEGER: number;
  73051. readonly RGBA_INTEGER: number;
  73052. readonly R8_SNORM: number;
  73053. readonly RG8_SNORM: number;
  73054. readonly RGB8_SNORM: number;
  73055. readonly RGBA8_SNORM: number;
  73056. readonly R8I: number;
  73057. readonly RG8I: number;
  73058. readonly RGB8I: number;
  73059. readonly RGBA8I: number;
  73060. readonly R8UI: number;
  73061. readonly RG8UI: number;
  73062. readonly RGB8UI: number;
  73063. readonly RGBA8UI: number;
  73064. readonly R16I: number;
  73065. readonly RG16I: number;
  73066. readonly RGB16I: number;
  73067. readonly RGBA16I: number;
  73068. readonly R16UI: number;
  73069. readonly RG16UI: number;
  73070. readonly RGB16UI: number;
  73071. readonly RGBA16UI: number;
  73072. readonly R32I: number;
  73073. readonly RG32I: number;
  73074. readonly RGB32I: number;
  73075. readonly RGBA32I: number;
  73076. readonly R32UI: number;
  73077. readonly RG32UI: number;
  73078. readonly RGB32UI: number;
  73079. readonly RGBA32UI: number;
  73080. readonly RGB10_A2UI: number;
  73081. readonly R11F_G11F_B10F: number;
  73082. readonly RGB9_E5: number;
  73083. readonly RGB10_A2: number;
  73084. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73085. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73086. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73087. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73088. readonly DEPTH_COMPONENT32F: number;
  73089. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73090. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73091. 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;
  73092. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73093. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73094. readonly TRANSFORM_FEEDBACK: number;
  73095. readonly INTERLEAVED_ATTRIBS: number;
  73096. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73097. createTransformFeedback(): WebGLTransformFeedback;
  73098. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73099. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73100. beginTransformFeedback(primitiveMode: number): void;
  73101. endTransformFeedback(): void;
  73102. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73103. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73104. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73105. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73106. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73107. }
  73108. interface ImageBitmap {
  73109. readonly width: number;
  73110. readonly height: number;
  73111. close(): void;
  73112. }
  73113. interface WebGLQuery extends WebGLObject {
  73114. }
  73115. declare var WebGLQuery: {
  73116. prototype: WebGLQuery;
  73117. new(): WebGLQuery;
  73118. };
  73119. interface WebGLSampler extends WebGLObject {
  73120. }
  73121. declare var WebGLSampler: {
  73122. prototype: WebGLSampler;
  73123. new(): WebGLSampler;
  73124. };
  73125. interface WebGLSync extends WebGLObject {
  73126. }
  73127. declare var WebGLSync: {
  73128. prototype: WebGLSync;
  73129. new(): WebGLSync;
  73130. };
  73131. interface WebGLTransformFeedback extends WebGLObject {
  73132. }
  73133. declare var WebGLTransformFeedback: {
  73134. prototype: WebGLTransformFeedback;
  73135. new(): WebGLTransformFeedback;
  73136. };
  73137. interface WebGLVertexArrayObject extends WebGLObject {
  73138. }
  73139. declare var WebGLVertexArrayObject: {
  73140. prototype: WebGLVertexArrayObject;
  73141. new(): WebGLVertexArrayObject;
  73142. };
  73143. // Type definitions for WebVR API
  73144. // Project: https://w3c.github.io/webvr/
  73145. // Definitions by: six a <https://github.com/lostfictions>
  73146. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73147. interface VRDisplay extends EventTarget {
  73148. /**
  73149. * Dictionary of capabilities describing the VRDisplay.
  73150. */
  73151. readonly capabilities: VRDisplayCapabilities;
  73152. /**
  73153. * z-depth defining the far plane of the eye view frustum
  73154. * enables mapping of values in the render target depth
  73155. * attachment to scene coordinates. Initially set to 10000.0.
  73156. */
  73157. depthFar: number;
  73158. /**
  73159. * z-depth defining the near plane of the eye view frustum
  73160. * enables mapping of values in the render target depth
  73161. * attachment to scene coordinates. Initially set to 0.01.
  73162. */
  73163. depthNear: number;
  73164. /**
  73165. * An identifier for this distinct VRDisplay. Used as an
  73166. * association point in the Gamepad API.
  73167. */
  73168. readonly displayId: number;
  73169. /**
  73170. * A display name, a user-readable name identifying it.
  73171. */
  73172. readonly displayName: string;
  73173. readonly isConnected: boolean;
  73174. readonly isPresenting: boolean;
  73175. /**
  73176. * If this VRDisplay supports room-scale experiences, the optional
  73177. * stage attribute contains details on the room-scale parameters.
  73178. */
  73179. readonly stageParameters: VRStageParameters | null;
  73180. /**
  73181. * Passing the value returned by `requestAnimationFrame` to
  73182. * `cancelAnimationFrame` will unregister the callback.
  73183. * @param handle Define the hanle of the request to cancel
  73184. */
  73185. cancelAnimationFrame(handle: number): void;
  73186. /**
  73187. * Stops presenting to the VRDisplay.
  73188. * @returns a promise to know when it stopped
  73189. */
  73190. exitPresent(): Promise<void>;
  73191. /**
  73192. * Return the current VREyeParameters for the given eye.
  73193. * @param whichEye Define the eye we want the parameter for
  73194. * @returns the eye parameters
  73195. */
  73196. getEyeParameters(whichEye: string): VREyeParameters;
  73197. /**
  73198. * Populates the passed VRFrameData with the information required to render
  73199. * the current frame.
  73200. * @param frameData Define the data structure to populate
  73201. * @returns true if ok otherwise false
  73202. */
  73203. getFrameData(frameData: VRFrameData): boolean;
  73204. /**
  73205. * Get the layers currently being presented.
  73206. * @returns the list of VR layers
  73207. */
  73208. getLayers(): VRLayer[];
  73209. /**
  73210. * Return a VRPose containing the future predicted pose of the VRDisplay
  73211. * when the current frame will be presented. The value returned will not
  73212. * change until JavaScript has returned control to the browser.
  73213. *
  73214. * The VRPose will contain the position, orientation, velocity,
  73215. * and acceleration of each of these properties.
  73216. * @returns the pose object
  73217. */
  73218. getPose(): VRPose;
  73219. /**
  73220. * Return the current instantaneous pose of the VRDisplay, with no
  73221. * prediction applied.
  73222. * @returns the current instantaneous pose
  73223. */
  73224. getImmediatePose(): VRPose;
  73225. /**
  73226. * The callback passed to `requestAnimationFrame` will be called
  73227. * any time a new frame should be rendered. When the VRDisplay is
  73228. * presenting the callback will be called at the native refresh
  73229. * rate of the HMD. When not presenting this function acts
  73230. * identically to how window.requestAnimationFrame acts. Content should
  73231. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73232. * asynchronously from other displays and at differing refresh rates.
  73233. * @param callback Define the eaction to run next frame
  73234. * @returns the request handle it
  73235. */
  73236. requestAnimationFrame(callback: FrameRequestCallback): number;
  73237. /**
  73238. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73239. * Repeat calls while already presenting will update the VRLayers being displayed.
  73240. * @param layers Define the list of layer to present
  73241. * @returns a promise to know when the request has been fulfilled
  73242. */
  73243. requestPresent(layers: VRLayer[]): Promise<void>;
  73244. /**
  73245. * Reset the pose for this display, treating its current position and
  73246. * orientation as the "origin/zero" values. VRPose.position,
  73247. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73248. * updated when calling resetPose(). This should be called in only
  73249. * sitting-space experiences.
  73250. */
  73251. resetPose(): void;
  73252. /**
  73253. * The VRLayer provided to the VRDisplay will be captured and presented
  73254. * in the HMD. Calling this function has the same effect on the source
  73255. * canvas as any other operation that uses its source image, and canvases
  73256. * created without preserveDrawingBuffer set to true will be cleared.
  73257. * @param pose Define the pose to submit
  73258. */
  73259. submitFrame(pose?: VRPose): void;
  73260. }
  73261. declare var VRDisplay: {
  73262. prototype: VRDisplay;
  73263. new(): VRDisplay;
  73264. };
  73265. interface VRLayer {
  73266. leftBounds?: number[] | Float32Array | null;
  73267. rightBounds?: number[] | Float32Array | null;
  73268. source?: HTMLCanvasElement | null;
  73269. }
  73270. interface VRDisplayCapabilities {
  73271. readonly canPresent: boolean;
  73272. readonly hasExternalDisplay: boolean;
  73273. readonly hasOrientation: boolean;
  73274. readonly hasPosition: boolean;
  73275. readonly maxLayers: number;
  73276. }
  73277. interface VREyeParameters {
  73278. /** @deprecated */
  73279. readonly fieldOfView: VRFieldOfView;
  73280. readonly offset: Float32Array;
  73281. readonly renderHeight: number;
  73282. readonly renderWidth: number;
  73283. }
  73284. interface VRFieldOfView {
  73285. readonly downDegrees: number;
  73286. readonly leftDegrees: number;
  73287. readonly rightDegrees: number;
  73288. readonly upDegrees: number;
  73289. }
  73290. interface VRFrameData {
  73291. readonly leftProjectionMatrix: Float32Array;
  73292. readonly leftViewMatrix: Float32Array;
  73293. readonly pose: VRPose;
  73294. readonly rightProjectionMatrix: Float32Array;
  73295. readonly rightViewMatrix: Float32Array;
  73296. readonly timestamp: number;
  73297. }
  73298. interface VRPose {
  73299. readonly angularAcceleration: Float32Array | null;
  73300. readonly angularVelocity: Float32Array | null;
  73301. readonly linearAcceleration: Float32Array | null;
  73302. readonly linearVelocity: Float32Array | null;
  73303. readonly orientation: Float32Array | null;
  73304. readonly position: Float32Array | null;
  73305. readonly timestamp: number;
  73306. }
  73307. interface VRStageParameters {
  73308. sittingToStandingTransform?: Float32Array;
  73309. sizeX?: number;
  73310. sizeY?: number;
  73311. }
  73312. interface Navigator {
  73313. getVRDisplays(): Promise<VRDisplay[]>;
  73314. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73315. }
  73316. interface Window {
  73317. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73318. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73319. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73320. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73321. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73322. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73323. }
  73324. interface Gamepad {
  73325. readonly displayId: number;
  73326. }
  73327. type XRSessionMode =
  73328. | "inline"
  73329. | "immersive-vr"
  73330. | "immersive-ar";
  73331. type XRReferenceSpaceType =
  73332. | "viewer"
  73333. | "local"
  73334. | "local-floor"
  73335. | "bounded-floor"
  73336. | "unbounded";
  73337. type XREnvironmentBlendMode =
  73338. | "opaque"
  73339. | "additive"
  73340. | "alpha-blend";
  73341. type XRVisibilityState =
  73342. | "visible"
  73343. | "visible-blurred"
  73344. | "hidden";
  73345. type XRHandedness =
  73346. | "none"
  73347. | "left"
  73348. | "right";
  73349. type XRTargetRayMode =
  73350. | "gaze"
  73351. | "tracked-pointer"
  73352. | "screen";
  73353. type XREye =
  73354. | "none"
  73355. | "left"
  73356. | "right";
  73357. type XREventType =
  73358. | "devicechange"
  73359. | "visibilitychange"
  73360. | "end"
  73361. | "inputsourceschange"
  73362. | "select"
  73363. | "selectstart"
  73364. | "selectend"
  73365. | "squeeze"
  73366. | "squeezestart"
  73367. | "squeezeend"
  73368. | "reset";
  73369. interface XRSpace extends EventTarget {
  73370. }
  73371. interface XRRenderState {
  73372. depthNear?: number;
  73373. depthFar?: number;
  73374. inlineVerticalFieldOfView?: number;
  73375. baseLayer?: XRWebGLLayer;
  73376. }
  73377. interface XRInputSource {
  73378. handedness: XRHandedness;
  73379. targetRayMode: XRTargetRayMode;
  73380. targetRaySpace: XRSpace;
  73381. gripSpace: XRSpace | undefined;
  73382. gamepad: Gamepad | undefined;
  73383. profiles: Array<string>;
  73384. }
  73385. interface XRSessionInit {
  73386. optionalFeatures?: string[];
  73387. requiredFeatures?: string[];
  73388. }
  73389. interface XRSession extends XRAnchorCreator {
  73390. addEventListener: Function;
  73391. removeEventListener: Function;
  73392. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  73393. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  73394. requestAnimationFrame: Function;
  73395. end(): Promise<void>;
  73396. renderState: XRRenderState;
  73397. inputSources: Array<XRInputSource>;
  73398. // hit test
  73399. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  73400. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  73401. // legacy AR hit test
  73402. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73403. // legacy plane detection
  73404. updateWorldTrackingState(options: {
  73405. planeDetectionState?: { enabled: boolean; }
  73406. }): void;
  73407. }
  73408. interface XRReferenceSpace extends XRSpace {
  73409. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  73410. onreset: any;
  73411. }
  73412. type XRPlaneSet = Set<XRPlane>;
  73413. type XRAnchorSet = Set<XRAnchor>;
  73414. interface XRFrame {
  73415. session: XRSession;
  73416. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  73417. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  73418. // AR
  73419. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  73420. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  73421. // Anchors
  73422. trackedAnchors?: XRAnchorSet;
  73423. // Planes
  73424. worldInformation: {
  73425. detectedPlanes?: XRPlaneSet;
  73426. };
  73427. }
  73428. interface XRViewerPose extends XRPose {
  73429. views: Array<XRView>;
  73430. }
  73431. interface XRPose {
  73432. transform: XRRigidTransform;
  73433. emulatedPosition: boolean;
  73434. }
  73435. interface XRWebGLLayerOptions {
  73436. antialias?: boolean;
  73437. depth?: boolean;
  73438. stencil?: boolean;
  73439. alpha?: boolean;
  73440. multiview?: boolean;
  73441. framebufferScaleFactor?: number;
  73442. }
  73443. declare var XRWebGLLayer: {
  73444. prototype: XRWebGLLayer;
  73445. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  73446. };
  73447. interface XRWebGLLayer {
  73448. framebuffer: WebGLFramebuffer;
  73449. framebufferWidth: number;
  73450. framebufferHeight: number;
  73451. getViewport: Function;
  73452. }
  73453. declare class XRRigidTransform {
  73454. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  73455. position: DOMPointReadOnly;
  73456. orientation: DOMPointReadOnly;
  73457. matrix: Float32Array;
  73458. inverse: XRRigidTransform;
  73459. }
  73460. interface XRView {
  73461. eye: XREye;
  73462. projectionMatrix: Float32Array;
  73463. transform: XRRigidTransform;
  73464. }
  73465. interface XRInputSourceChangeEvent {
  73466. session: XRSession;
  73467. removed: Array<XRInputSource>;
  73468. added: Array<XRInputSource>;
  73469. }
  73470. interface XRInputSourceEvent extends Event {
  73471. readonly frame: XRFrame;
  73472. readonly inputSource: XRInputSource;
  73473. }
  73474. // Experimental(er) features
  73475. declare class XRRay {
  73476. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  73477. origin: DOMPointReadOnly;
  73478. direction: DOMPointReadOnly;
  73479. matrix: Float32Array;
  73480. }
  73481. declare enum XRHitTestTrackableType {
  73482. "point",
  73483. "plane"
  73484. }
  73485. interface XRHitResult {
  73486. hitMatrix: Float32Array;
  73487. }
  73488. interface XRTransientInputHitTestResult {
  73489. readonly inputSource: XRInputSource;
  73490. readonly results: Array<XRHitTestResult>;
  73491. }
  73492. interface XRHitTestResult {
  73493. getPose(baseSpace: XRSpace): XRPose | undefined;
  73494. }
  73495. interface XRHitTestSource {
  73496. cancel(): void;
  73497. }
  73498. interface XRTransientInputHitTestSource {
  73499. cancel(): void;
  73500. }
  73501. interface XRHitTestOptionsInit {
  73502. space: XRSpace;
  73503. entityTypes?: Array<XRHitTestTrackableType>;
  73504. offsetRay?: XRRay;
  73505. }
  73506. interface XRTransientInputHitTestOptionsInit {
  73507. profile: string;
  73508. entityTypes?: Array<XRHitTestTrackableType>;
  73509. offsetRay?: XRRay;
  73510. }
  73511. interface XRAnchor {
  73512. // remove?
  73513. id?: string;
  73514. anchorSpace: XRSpace;
  73515. lastChangedTime: number;
  73516. detach(): void;
  73517. }
  73518. interface XRPlane extends XRAnchorCreator {
  73519. orientation: "Horizontal" | "Vertical";
  73520. planeSpace: XRSpace;
  73521. polygon: Array<DOMPointReadOnly>;
  73522. lastChangedTime: number;
  73523. }
  73524. interface XRAnchorCreator {
  73525. // AR Anchors
  73526. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  73527. }
  73528. /**
  73529. * @ignore
  73530. */
  73531. declare module BABYLON.GLTF2.Exporter {
  73532. }
  73533. /**
  73534. * @ignore
  73535. */
  73536. declare module BABYLON.GLTF1 {
  73537. }
  73538. declare module BABYLON.GUI {
  73539. /**
  73540. * Class used to specific a value and its associated unit
  73541. */
  73542. export class ValueAndUnit {
  73543. /** defines the unit to store */
  73544. unit: number;
  73545. /** defines a boolean indicating if the value can be negative */
  73546. negativeValueAllowed: boolean;
  73547. private _value;
  73548. private _originalUnit;
  73549. /**
  73550. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  73551. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73552. */
  73553. ignoreAdaptiveScaling: boolean;
  73554. /**
  73555. * Creates a new ValueAndUnit
  73556. * @param value defines the value to store
  73557. * @param unit defines the unit to store
  73558. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  73559. */
  73560. constructor(value: number,
  73561. /** defines the unit to store */
  73562. unit?: number,
  73563. /** defines a boolean indicating if the value can be negative */
  73564. negativeValueAllowed?: boolean);
  73565. /** Gets a boolean indicating if the value is a percentage */
  73566. get isPercentage(): boolean;
  73567. /** Gets a boolean indicating if the value is store as pixel */
  73568. get isPixel(): boolean;
  73569. /** Gets direct internal value */
  73570. get internalValue(): number;
  73571. /**
  73572. * Gets value as pixel
  73573. * @param host defines the root host
  73574. * @param refValue defines the reference value for percentages
  73575. * @returns the value as pixel
  73576. */
  73577. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  73578. /**
  73579. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  73580. * @param value defines the value to store
  73581. * @param unit defines the unit to store
  73582. * @returns the current ValueAndUnit
  73583. */
  73584. updateInPlace(value: number, unit?: number): ValueAndUnit;
  73585. /**
  73586. * Gets the value accordingly to its unit
  73587. * @param host defines the root host
  73588. * @returns the value
  73589. */
  73590. getValue(host: AdvancedDynamicTexture): number;
  73591. /**
  73592. * Gets a string representation of the value
  73593. * @param host defines the root host
  73594. * @param decimals defines an optional number of decimals to display
  73595. * @returns a string
  73596. */
  73597. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  73598. /**
  73599. * Store a value parsed from a string
  73600. * @param source defines the source string
  73601. * @returns true if the value was successfully parsed
  73602. */
  73603. fromString(source: string | number): boolean;
  73604. private static _Regex;
  73605. private static _UNITMODE_PERCENTAGE;
  73606. private static _UNITMODE_PIXEL;
  73607. /** UNITMODE_PERCENTAGE */
  73608. static get UNITMODE_PERCENTAGE(): number;
  73609. /** UNITMODE_PIXEL */
  73610. static get UNITMODE_PIXEL(): number;
  73611. }
  73612. }
  73613. declare module BABYLON.GUI {
  73614. /**
  73615. * Define a style used by control to automatically setup properties based on a template.
  73616. * Only support font related properties so far
  73617. */
  73618. export class Style implements BABYLON.IDisposable {
  73619. private _fontFamily;
  73620. private _fontStyle;
  73621. private _fontWeight;
  73622. /** @hidden */
  73623. _host: AdvancedDynamicTexture;
  73624. /** @hidden */
  73625. _fontSize: ValueAndUnit;
  73626. /**
  73627. * BABYLON.Observable raised when the style values are changed
  73628. */
  73629. onChangedObservable: BABYLON.Observable<Style>;
  73630. /**
  73631. * Creates a new style object
  73632. * @param host defines the AdvancedDynamicTexture which hosts this style
  73633. */
  73634. constructor(host: AdvancedDynamicTexture);
  73635. /**
  73636. * Gets or sets the font size
  73637. */
  73638. get fontSize(): string | number;
  73639. set fontSize(value: string | number);
  73640. /**
  73641. * Gets or sets the font family
  73642. */
  73643. get fontFamily(): string;
  73644. set fontFamily(value: string);
  73645. /**
  73646. * Gets or sets the font style
  73647. */
  73648. get fontStyle(): string;
  73649. set fontStyle(value: string);
  73650. /** Gets or sets font weight */
  73651. get fontWeight(): string;
  73652. set fontWeight(value: string);
  73653. /** Dispose all associated resources */
  73654. dispose(): void;
  73655. }
  73656. }
  73657. declare module BABYLON.GUI {
  73658. /**
  73659. * Class used to transport BABYLON.Vector2 information for pointer events
  73660. */
  73661. export class Vector2WithInfo extends BABYLON.Vector2 {
  73662. /** defines the current mouse button index */
  73663. buttonIndex: number;
  73664. /**
  73665. * Creates a new Vector2WithInfo
  73666. * @param source defines the vector2 data to transport
  73667. * @param buttonIndex defines the current mouse button index
  73668. */
  73669. constructor(source: BABYLON.Vector2,
  73670. /** defines the current mouse button index */
  73671. buttonIndex?: number);
  73672. }
  73673. /** Class used to provide 2D matrix features */
  73674. export class Matrix2D {
  73675. /** Gets the internal array of 6 floats used to store matrix data */
  73676. m: Float32Array;
  73677. /**
  73678. * Creates a new matrix
  73679. * @param m00 defines value for (0, 0)
  73680. * @param m01 defines value for (0, 1)
  73681. * @param m10 defines value for (1, 0)
  73682. * @param m11 defines value for (1, 1)
  73683. * @param m20 defines value for (2, 0)
  73684. * @param m21 defines value for (2, 1)
  73685. */
  73686. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  73687. /**
  73688. * Fills the matrix from direct values
  73689. * @param m00 defines value for (0, 0)
  73690. * @param m01 defines value for (0, 1)
  73691. * @param m10 defines value for (1, 0)
  73692. * @param m11 defines value for (1, 1)
  73693. * @param m20 defines value for (2, 0)
  73694. * @param m21 defines value for (2, 1)
  73695. * @returns the current modified matrix
  73696. */
  73697. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  73698. /**
  73699. * Gets matrix determinant
  73700. * @returns the determinant
  73701. */
  73702. determinant(): number;
  73703. /**
  73704. * Inverses the matrix and stores it in a target matrix
  73705. * @param result defines the target matrix
  73706. * @returns the current matrix
  73707. */
  73708. invertToRef(result: Matrix2D): Matrix2D;
  73709. /**
  73710. * Multiplies the current matrix with another one
  73711. * @param other defines the second operand
  73712. * @param result defines the target matrix
  73713. * @returns the current matrix
  73714. */
  73715. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  73716. /**
  73717. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  73718. * @param x defines the x coordinate to transform
  73719. * @param y defines the x coordinate to transform
  73720. * @param result defines the target vector2
  73721. * @returns the current matrix
  73722. */
  73723. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  73724. /**
  73725. * Creates an identity matrix
  73726. * @returns a new matrix
  73727. */
  73728. static Identity(): Matrix2D;
  73729. /**
  73730. * Creates a translation matrix and stores it in a target matrix
  73731. * @param x defines the x coordinate of the translation
  73732. * @param y defines the y coordinate of the translation
  73733. * @param result defines the target matrix
  73734. */
  73735. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  73736. /**
  73737. * Creates a scaling matrix and stores it in a target matrix
  73738. * @param x defines the x coordinate of the scaling
  73739. * @param y defines the y coordinate of the scaling
  73740. * @param result defines the target matrix
  73741. */
  73742. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  73743. /**
  73744. * Creates a rotation matrix and stores it in a target matrix
  73745. * @param angle defines the rotation angle
  73746. * @param result defines the target matrix
  73747. */
  73748. static RotationToRef(angle: number, result: Matrix2D): void;
  73749. private static _TempPreTranslationMatrix;
  73750. private static _TempPostTranslationMatrix;
  73751. private static _TempRotationMatrix;
  73752. private static _TempScalingMatrix;
  73753. private static _TempCompose0;
  73754. private static _TempCompose1;
  73755. private static _TempCompose2;
  73756. /**
  73757. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  73758. * @param tx defines the x coordinate of the translation
  73759. * @param ty defines the y coordinate of the translation
  73760. * @param angle defines the rotation angle
  73761. * @param scaleX defines the x coordinate of the scaling
  73762. * @param scaleY defines the y coordinate of the scaling
  73763. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  73764. * @param result defines the target matrix
  73765. */
  73766. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  73767. }
  73768. }
  73769. declare module BABYLON.GUI {
  73770. /**
  73771. * Class used to store 2D control sizes
  73772. */
  73773. export class Measure {
  73774. /** defines left coordinate */
  73775. left: number;
  73776. /** defines top coordinate */
  73777. top: number;
  73778. /** defines width dimension */
  73779. width: number;
  73780. /** defines height dimension */
  73781. height: number;
  73782. /**
  73783. * Creates a new measure
  73784. * @param left defines left coordinate
  73785. * @param top defines top coordinate
  73786. * @param width defines width dimension
  73787. * @param height defines height dimension
  73788. */
  73789. constructor(
  73790. /** defines left coordinate */
  73791. left: number,
  73792. /** defines top coordinate */
  73793. top: number,
  73794. /** defines width dimension */
  73795. width: number,
  73796. /** defines height dimension */
  73797. height: number);
  73798. /**
  73799. * Copy from another measure
  73800. * @param other defines the other measure to copy from
  73801. */
  73802. copyFrom(other: Measure): void;
  73803. /**
  73804. * Copy from a group of 4 floats
  73805. * @param left defines left coordinate
  73806. * @param top defines top coordinate
  73807. * @param width defines width dimension
  73808. * @param height defines height dimension
  73809. */
  73810. copyFromFloats(left: number, top: number, width: number, height: number): void;
  73811. /**
  73812. * Computes the axis aligned bounding box measure for two given measures
  73813. * @param a Input measure
  73814. * @param b Input measure
  73815. * @param result the resulting bounding measure
  73816. */
  73817. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  73818. /**
  73819. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  73820. * @param transform the matrix to transform the measure before computing the AABB
  73821. * @param result the resulting AABB
  73822. */
  73823. transformToRef(transform: Matrix2D, result: Measure): void;
  73824. /**
  73825. * Check equality between this measure and another one
  73826. * @param other defines the other measures
  73827. * @returns true if both measures are equals
  73828. */
  73829. isEqualsTo(other: Measure): boolean;
  73830. /**
  73831. * Creates an empty measure
  73832. * @returns a new measure
  73833. */
  73834. static Empty(): Measure;
  73835. }
  73836. }
  73837. declare module BABYLON.GUI {
  73838. /**
  73839. * Interface used to define a control that can receive focus
  73840. */
  73841. export interface IFocusableControl {
  73842. /**
  73843. * Function called when the control receives the focus
  73844. */
  73845. onFocus(): void;
  73846. /**
  73847. * Function called when the control loses the focus
  73848. */
  73849. onBlur(): void;
  73850. /**
  73851. * Function called to let the control handle keyboard events
  73852. * @param evt defines the current keyboard event
  73853. */
  73854. processKeyboard(evt: KeyboardEvent): void;
  73855. /**
  73856. * Function called to get the list of controls that should not steal the focus from this control
  73857. * @returns an array of controls
  73858. */
  73859. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73860. }
  73861. /**
  73862. * Class used to create texture to support 2D GUI elements
  73863. * @see http://doc.babylonjs.com/how_to/gui
  73864. */
  73865. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  73866. private _isDirty;
  73867. private _renderObserver;
  73868. private _resizeObserver;
  73869. private _preKeyboardObserver;
  73870. private _pointerMoveObserver;
  73871. private _pointerObserver;
  73872. private _canvasPointerOutObserver;
  73873. private _background;
  73874. /** @hidden */
  73875. _rootContainer: Container;
  73876. /** @hidden */
  73877. _lastPickedControl: Control;
  73878. /** @hidden */
  73879. _lastControlOver: {
  73880. [pointerId: number]: Control;
  73881. };
  73882. /** @hidden */
  73883. _lastControlDown: {
  73884. [pointerId: number]: Control;
  73885. };
  73886. /** @hidden */
  73887. _capturingControl: {
  73888. [pointerId: number]: Control;
  73889. };
  73890. /** @hidden */
  73891. _shouldBlockPointer: boolean;
  73892. /** @hidden */
  73893. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  73894. /** @hidden */
  73895. _linkedControls: Control[];
  73896. private _isFullscreen;
  73897. private _fullscreenViewport;
  73898. private _idealWidth;
  73899. private _idealHeight;
  73900. private _useSmallestIdeal;
  73901. private _renderAtIdealSize;
  73902. private _focusedControl;
  73903. private _blockNextFocusCheck;
  73904. private _renderScale;
  73905. private _rootElement;
  73906. private _cursorChanged;
  73907. private _defaultMousePointerId;
  73908. /** @hidden */
  73909. _numLayoutCalls: number;
  73910. /** Gets the number of layout calls made the last time the ADT has been rendered */
  73911. get numLayoutCalls(): number;
  73912. /** @hidden */
  73913. _numRenderCalls: number;
  73914. /** Gets the number of render calls made the last time the ADT has been rendered */
  73915. get numRenderCalls(): number;
  73916. /**
  73917. * Define type to string to ensure compatibility across browsers
  73918. * Safari doesn't support DataTransfer constructor
  73919. */
  73920. private _clipboardData;
  73921. /**
  73922. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  73923. */
  73924. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  73925. /**
  73926. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  73927. */
  73928. onControlPickedObservable: BABYLON.Observable<Control>;
  73929. /**
  73930. * BABYLON.Observable event triggered before layout is evaluated
  73931. */
  73932. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73933. /**
  73934. * BABYLON.Observable event triggered after the layout was evaluated
  73935. */
  73936. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73937. /**
  73938. * BABYLON.Observable event triggered before the texture is rendered
  73939. */
  73940. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73941. /**
  73942. * BABYLON.Observable event triggered after the texture was rendered
  73943. */
  73944. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73945. /**
  73946. * Gets or sets a boolean defining if alpha is stored as premultiplied
  73947. */
  73948. premulAlpha: boolean;
  73949. /**
  73950. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  73951. * Useful when you want more antialiasing
  73952. */
  73953. get renderScale(): number;
  73954. set renderScale(value: number);
  73955. /** Gets or sets the background color */
  73956. get background(): string;
  73957. set background(value: string);
  73958. /**
  73959. * Gets or sets the ideal width used to design controls.
  73960. * The GUI will then rescale everything accordingly
  73961. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73962. */
  73963. get idealWidth(): number;
  73964. set idealWidth(value: number);
  73965. /**
  73966. * Gets or sets the ideal height used to design controls.
  73967. * The GUI will then rescale everything accordingly
  73968. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73969. */
  73970. get idealHeight(): number;
  73971. set idealHeight(value: number);
  73972. /**
  73973. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  73974. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73975. */
  73976. get useSmallestIdeal(): boolean;
  73977. set useSmallestIdeal(value: boolean);
  73978. /**
  73979. * Gets or sets a boolean indicating if adaptive scaling must be used
  73980. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73981. */
  73982. get renderAtIdealSize(): boolean;
  73983. set renderAtIdealSize(value: boolean);
  73984. /**
  73985. * Gets the ratio used when in "ideal mode"
  73986. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73987. * */
  73988. get idealRatio(): number;
  73989. /**
  73990. * Gets the underlying layer used to render the texture when in fullscreen mode
  73991. */
  73992. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  73993. /**
  73994. * Gets the root container control
  73995. */
  73996. get rootContainer(): Container;
  73997. /**
  73998. * Returns an array containing the root container.
  73999. * This is mostly used to let the Inspector introspects the ADT
  74000. * @returns an array containing the rootContainer
  74001. */
  74002. getChildren(): Array<Container>;
  74003. /**
  74004. * Will return all controls that are inside this texture
  74005. * @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
  74006. * @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
  74007. * @return all child controls
  74008. */
  74009. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74010. /**
  74011. * Gets or sets the current focused control
  74012. */
  74013. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  74014. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  74015. /**
  74016. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  74017. */
  74018. get isForeground(): boolean;
  74019. set isForeground(value: boolean);
  74020. /**
  74021. * Gets or set information about clipboardData
  74022. */
  74023. get clipboardData(): string;
  74024. set clipboardData(value: string);
  74025. /**
  74026. * Creates a new AdvancedDynamicTexture
  74027. * @param name defines the name of the texture
  74028. * @param width defines the width of the texture
  74029. * @param height defines the height of the texture
  74030. * @param scene defines the hosting scene
  74031. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  74032. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  74033. */
  74034. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74035. /**
  74036. * Get the current class name of the texture useful for serialization or dynamic coding.
  74037. * @returns "AdvancedDynamicTexture"
  74038. */
  74039. getClassName(): string;
  74040. /**
  74041. * Function used to execute a function on all controls
  74042. * @param func defines the function to execute
  74043. * @param container defines the container where controls belong. If null the root container will be used
  74044. */
  74045. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74046. private _useInvalidateRectOptimization;
  74047. /**
  74048. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74049. */
  74050. get useInvalidateRectOptimization(): boolean;
  74051. set useInvalidateRectOptimization(value: boolean);
  74052. private _invalidatedRectangle;
  74053. /**
  74054. * Invalidates a rectangle area on the gui texture
  74055. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74056. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74057. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74058. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74059. */
  74060. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74061. /**
  74062. * Marks the texture as dirty forcing a complete update
  74063. */
  74064. markAsDirty(): void;
  74065. /**
  74066. * Helper function used to create a new style
  74067. * @returns a new style
  74068. * @see http://doc.babylonjs.com/how_to/gui#styles
  74069. */
  74070. createStyle(): Style;
  74071. /**
  74072. * Adds a new control to the root container
  74073. * @param control defines the control to add
  74074. * @returns the current texture
  74075. */
  74076. addControl(control: Control): AdvancedDynamicTexture;
  74077. /**
  74078. * Removes a control from the root container
  74079. * @param control defines the control to remove
  74080. * @returns the current texture
  74081. */
  74082. removeControl(control: Control): AdvancedDynamicTexture;
  74083. /**
  74084. * Release all resources
  74085. */
  74086. dispose(): void;
  74087. private _onResize;
  74088. /** @hidden */
  74089. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74090. /**
  74091. * Get screen coordinates for a vector3
  74092. * @param position defines the position to project
  74093. * @param worldMatrix defines the world matrix to use
  74094. * @returns the projected position
  74095. */
  74096. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74097. private _checkUpdate;
  74098. private _clearMeasure;
  74099. private _render;
  74100. /** @hidden */
  74101. _changeCursor(cursor: string): void;
  74102. /** @hidden */
  74103. _registerLastControlDown(control: Control, pointerId: number): void;
  74104. private _doPicking;
  74105. /** @hidden */
  74106. _cleanControlAfterRemovalFromList(list: {
  74107. [pointerId: number]: Control;
  74108. }, control: Control): void;
  74109. /** @hidden */
  74110. _cleanControlAfterRemoval(control: Control): void;
  74111. /** Attach to all scene events required to support pointer events */
  74112. attach(): void;
  74113. /** @hidden */
  74114. private onClipboardCopy;
  74115. /** @hidden */
  74116. private onClipboardCut;
  74117. /** @hidden */
  74118. private onClipboardPaste;
  74119. /**
  74120. * Register the clipboard Events onto the canvas
  74121. */
  74122. registerClipboardEvents(): void;
  74123. /**
  74124. * Unregister the clipboard Events from the canvas
  74125. */
  74126. unRegisterClipboardEvents(): void;
  74127. /**
  74128. * Connect the texture to a hosting mesh to enable interactions
  74129. * @param mesh defines the mesh to attach to
  74130. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74131. */
  74132. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74133. /**
  74134. * Move the focus to a specific control
  74135. * @param control defines the control which will receive the focus
  74136. */
  74137. moveFocusToControl(control: IFocusableControl): void;
  74138. private _manageFocus;
  74139. private _attachToOnPointerOut;
  74140. /**
  74141. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74142. * @param mesh defines the mesh which will receive the texture
  74143. * @param width defines the texture width (1024 by default)
  74144. * @param height defines the texture height (1024 by default)
  74145. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74146. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74147. * @returns a new AdvancedDynamicTexture
  74148. */
  74149. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74150. /**
  74151. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74152. * In this mode the texture will rely on a layer for its rendering.
  74153. * This allows it to be treated like any other layer.
  74154. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74155. * LayerMask is set through advancedTexture.layer.layerMask
  74156. * @param name defines name for the texture
  74157. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74158. * @param scene defines the hsoting scene
  74159. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74160. * @returns a new AdvancedDynamicTexture
  74161. */
  74162. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74163. }
  74164. }
  74165. declare module BABYLON.GUI {
  74166. /**
  74167. * Root class used for all 2D controls
  74168. * @see http://doc.babylonjs.com/how_to/gui#controls
  74169. */
  74170. export class Control {
  74171. /** defines the name of the control */
  74172. name?: string | undefined;
  74173. /**
  74174. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74175. */
  74176. static AllowAlphaInheritance: boolean;
  74177. private _alpha;
  74178. private _alphaSet;
  74179. private _zIndex;
  74180. /** @hidden */
  74181. _host: AdvancedDynamicTexture;
  74182. /** Gets or sets the control parent */
  74183. parent: BABYLON.Nullable<Container>;
  74184. /** @hidden */
  74185. _currentMeasure: Measure;
  74186. private _fontFamily;
  74187. private _fontStyle;
  74188. private _fontWeight;
  74189. private _fontSize;
  74190. private _font;
  74191. /** @hidden */
  74192. _width: ValueAndUnit;
  74193. /** @hidden */
  74194. _height: ValueAndUnit;
  74195. /** @hidden */
  74196. protected _fontOffset: {
  74197. ascent: number;
  74198. height: number;
  74199. descent: number;
  74200. };
  74201. private _color;
  74202. private _style;
  74203. private _styleObserver;
  74204. /** @hidden */
  74205. protected _horizontalAlignment: number;
  74206. /** @hidden */
  74207. protected _verticalAlignment: number;
  74208. /** @hidden */
  74209. protected _isDirty: boolean;
  74210. /** @hidden */
  74211. protected _wasDirty: boolean;
  74212. /** @hidden */
  74213. _tempParentMeasure: Measure;
  74214. /** @hidden */
  74215. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74216. /** @hidden */
  74217. protected _cachedParentMeasure: Measure;
  74218. private _paddingLeft;
  74219. private _paddingRight;
  74220. private _paddingTop;
  74221. private _paddingBottom;
  74222. /** @hidden */
  74223. _left: ValueAndUnit;
  74224. /** @hidden */
  74225. _top: ValueAndUnit;
  74226. private _scaleX;
  74227. private _scaleY;
  74228. private _rotation;
  74229. private _transformCenterX;
  74230. private _transformCenterY;
  74231. /** @hidden */
  74232. _transformMatrix: Matrix2D;
  74233. /** @hidden */
  74234. protected _invertTransformMatrix: Matrix2D;
  74235. /** @hidden */
  74236. protected _transformedPosition: BABYLON.Vector2;
  74237. private _isMatrixDirty;
  74238. private _cachedOffsetX;
  74239. private _cachedOffsetY;
  74240. private _isVisible;
  74241. private _isHighlighted;
  74242. /** @hidden */
  74243. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74244. private _fontSet;
  74245. private _dummyVector2;
  74246. private _downCount;
  74247. private _enterCount;
  74248. private _doNotRender;
  74249. private _downPointerIds;
  74250. protected _isEnabled: boolean;
  74251. protected _disabledColor: string;
  74252. protected _disabledColorItem: string;
  74253. /** @hidden */
  74254. protected _rebuildLayout: boolean;
  74255. /** @hidden */
  74256. _customData: any;
  74257. /** @hidden */
  74258. _isClipped: boolean;
  74259. /** @hidden */
  74260. _automaticSize: boolean;
  74261. /** @hidden */
  74262. _tag: any;
  74263. /**
  74264. * 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
  74265. */
  74266. uniqueId: number;
  74267. /**
  74268. * Gets or sets an object used to store user defined information for the node
  74269. */
  74270. metadata: any;
  74271. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74272. isHitTestVisible: boolean;
  74273. /** Gets or sets a boolean indicating if the control can block pointer events */
  74274. isPointerBlocker: boolean;
  74275. /** Gets or sets a boolean indicating if the control can be focusable */
  74276. isFocusInvisible: boolean;
  74277. /**
  74278. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74279. * 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
  74280. */
  74281. clipChildren: boolean;
  74282. /**
  74283. * Gets or sets a boolean indicating that control content must be clipped
  74284. * 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
  74285. */
  74286. clipContent: boolean;
  74287. /**
  74288. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74289. */
  74290. useBitmapCache: boolean;
  74291. private _cacheData;
  74292. private _shadowOffsetX;
  74293. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74294. get shadowOffsetX(): number;
  74295. set shadowOffsetX(value: number);
  74296. private _shadowOffsetY;
  74297. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74298. get shadowOffsetY(): number;
  74299. set shadowOffsetY(value: number);
  74300. private _shadowBlur;
  74301. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74302. get shadowBlur(): number;
  74303. set shadowBlur(value: number);
  74304. private _shadowColor;
  74305. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74306. get shadowColor(): string;
  74307. set shadowColor(value: string);
  74308. /** Gets or sets the cursor to use when the control is hovered */
  74309. hoverCursor: string;
  74310. /** @hidden */
  74311. protected _linkOffsetX: ValueAndUnit;
  74312. /** @hidden */
  74313. protected _linkOffsetY: ValueAndUnit;
  74314. /** Gets the control type name */
  74315. get typeName(): string;
  74316. /**
  74317. * Get the current class name of the control.
  74318. * @returns current class name
  74319. */
  74320. getClassName(): string;
  74321. /**
  74322. * An event triggered when pointer wheel is scrolled
  74323. */
  74324. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74325. /**
  74326. * An event triggered when the pointer move over the control.
  74327. */
  74328. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74329. /**
  74330. * An event triggered when the pointer move out of the control.
  74331. */
  74332. onPointerOutObservable: BABYLON.Observable<Control>;
  74333. /**
  74334. * An event triggered when the pointer taps the control
  74335. */
  74336. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74337. /**
  74338. * An event triggered when pointer up
  74339. */
  74340. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74341. /**
  74342. * An event triggered when a control is clicked on
  74343. */
  74344. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74345. /**
  74346. * An event triggered when pointer enters the control
  74347. */
  74348. onPointerEnterObservable: BABYLON.Observable<Control>;
  74349. /**
  74350. * An event triggered when the control is marked as dirty
  74351. */
  74352. onDirtyObservable: BABYLON.Observable<Control>;
  74353. /**
  74354. * An event triggered before drawing the control
  74355. */
  74356. onBeforeDrawObservable: BABYLON.Observable<Control>;
  74357. /**
  74358. * An event triggered after the control was drawn
  74359. */
  74360. onAfterDrawObservable: BABYLON.Observable<Control>;
  74361. /**
  74362. * An event triggered when the control has been disposed
  74363. */
  74364. onDisposeObservable: BABYLON.Observable<Control>;
  74365. /**
  74366. * Get the hosting AdvancedDynamicTexture
  74367. */
  74368. get host(): AdvancedDynamicTexture;
  74369. /** Gets or set information about font offsets (used to render and align text) */
  74370. get fontOffset(): {
  74371. ascent: number;
  74372. height: number;
  74373. descent: number;
  74374. };
  74375. set fontOffset(offset: {
  74376. ascent: number;
  74377. height: number;
  74378. descent: number;
  74379. });
  74380. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  74381. get alpha(): number;
  74382. set alpha(value: number);
  74383. /**
  74384. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  74385. */
  74386. get isHighlighted(): boolean;
  74387. set isHighlighted(value: boolean);
  74388. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  74389. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74390. */
  74391. get scaleX(): number;
  74392. set scaleX(value: number);
  74393. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  74394. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74395. */
  74396. get scaleY(): number;
  74397. set scaleY(value: number);
  74398. /** Gets or sets the rotation angle (0 by default)
  74399. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74400. */
  74401. get rotation(): number;
  74402. set rotation(value: number);
  74403. /** Gets or sets the transformation center on Y axis (0 by default)
  74404. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74405. */
  74406. get transformCenterY(): number;
  74407. set transformCenterY(value: number);
  74408. /** Gets or sets the transformation center on X axis (0 by default)
  74409. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74410. */
  74411. get transformCenterX(): number;
  74412. set transformCenterX(value: number);
  74413. /**
  74414. * Gets or sets the horizontal alignment
  74415. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74416. */
  74417. get horizontalAlignment(): number;
  74418. set horizontalAlignment(value: number);
  74419. /**
  74420. * Gets or sets the vertical alignment
  74421. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74422. */
  74423. get verticalAlignment(): number;
  74424. set verticalAlignment(value: number);
  74425. /**
  74426. * Gets or sets control width
  74427. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74428. */
  74429. get width(): string | number;
  74430. set width(value: string | number);
  74431. /**
  74432. * Gets or sets the control width in pixel
  74433. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74434. */
  74435. get widthInPixels(): number;
  74436. set widthInPixels(value: number);
  74437. /**
  74438. * Gets or sets control height
  74439. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74440. */
  74441. get height(): string | number;
  74442. set height(value: string | number);
  74443. /**
  74444. * Gets or sets control height in pixel
  74445. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74446. */
  74447. get heightInPixels(): number;
  74448. set heightInPixels(value: number);
  74449. /** Gets or set font family */
  74450. get fontFamily(): string;
  74451. set fontFamily(value: string);
  74452. /** Gets or sets font style */
  74453. get fontStyle(): string;
  74454. set fontStyle(value: string);
  74455. /** Gets or sets font weight */
  74456. get fontWeight(): string;
  74457. set fontWeight(value: string);
  74458. /**
  74459. * Gets or sets style
  74460. * @see http://doc.babylonjs.com/how_to/gui#styles
  74461. */
  74462. get style(): BABYLON.Nullable<Style>;
  74463. set style(value: BABYLON.Nullable<Style>);
  74464. /** @hidden */
  74465. get _isFontSizeInPercentage(): boolean;
  74466. /** Gets or sets font size in pixels */
  74467. get fontSizeInPixels(): number;
  74468. set fontSizeInPixels(value: number);
  74469. /** Gets or sets font size */
  74470. get fontSize(): string | number;
  74471. set fontSize(value: string | number);
  74472. /** Gets or sets foreground color */
  74473. get color(): string;
  74474. set color(value: string);
  74475. /** Gets or sets z index which is used to reorder controls on the z axis */
  74476. get zIndex(): number;
  74477. set zIndex(value: number);
  74478. /** Gets or sets a boolean indicating if the control can be rendered */
  74479. get notRenderable(): boolean;
  74480. set notRenderable(value: boolean);
  74481. /** Gets or sets a boolean indicating if the control is visible */
  74482. get isVisible(): boolean;
  74483. set isVisible(value: boolean);
  74484. /** Gets a boolean indicating that the control needs to update its rendering */
  74485. get isDirty(): boolean;
  74486. /**
  74487. * Gets the current linked mesh (or null if none)
  74488. */
  74489. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74490. /**
  74491. * Gets or sets a value indicating the padding to use on the left of the control
  74492. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74493. */
  74494. get paddingLeft(): string | number;
  74495. set paddingLeft(value: string | number);
  74496. /**
  74497. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  74498. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74499. */
  74500. get paddingLeftInPixels(): number;
  74501. set paddingLeftInPixels(value: number);
  74502. /**
  74503. * Gets or sets a value indicating the padding to use on the right of the control
  74504. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74505. */
  74506. get paddingRight(): string | number;
  74507. set paddingRight(value: string | number);
  74508. /**
  74509. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  74510. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74511. */
  74512. get paddingRightInPixels(): number;
  74513. set paddingRightInPixels(value: number);
  74514. /**
  74515. * Gets or sets a value indicating the padding to use on the top of the control
  74516. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74517. */
  74518. get paddingTop(): string | number;
  74519. set paddingTop(value: string | number);
  74520. /**
  74521. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  74522. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74523. */
  74524. get paddingTopInPixels(): number;
  74525. set paddingTopInPixels(value: number);
  74526. /**
  74527. * Gets or sets a value indicating the padding to use on the bottom of the control
  74528. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74529. */
  74530. get paddingBottom(): string | number;
  74531. set paddingBottom(value: string | number);
  74532. /**
  74533. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  74534. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74535. */
  74536. get paddingBottomInPixels(): number;
  74537. set paddingBottomInPixels(value: number);
  74538. /**
  74539. * Gets or sets a value indicating the left coordinate of the control
  74540. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74541. */
  74542. get left(): string | number;
  74543. set left(value: string | number);
  74544. /**
  74545. * Gets or sets a value indicating the left coordinate in pixels of the control
  74546. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74547. */
  74548. get leftInPixels(): number;
  74549. set leftInPixels(value: number);
  74550. /**
  74551. * Gets or sets a value indicating the top coordinate of the control
  74552. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74553. */
  74554. get top(): string | number;
  74555. set top(value: string | number);
  74556. /**
  74557. * Gets or sets a value indicating the top coordinate in pixels of the control
  74558. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74559. */
  74560. get topInPixels(): number;
  74561. set topInPixels(value: number);
  74562. /**
  74563. * Gets or sets a value indicating the offset on X axis to the linked mesh
  74564. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74565. */
  74566. get linkOffsetX(): string | number;
  74567. set linkOffsetX(value: string | number);
  74568. /**
  74569. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  74570. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74571. */
  74572. get linkOffsetXInPixels(): number;
  74573. set linkOffsetXInPixels(value: number);
  74574. /**
  74575. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  74576. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74577. */
  74578. get linkOffsetY(): string | number;
  74579. set linkOffsetY(value: string | number);
  74580. /**
  74581. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  74582. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74583. */
  74584. get linkOffsetYInPixels(): number;
  74585. set linkOffsetYInPixels(value: number);
  74586. /** Gets the center coordinate on X axis */
  74587. get centerX(): number;
  74588. /** Gets the center coordinate on Y axis */
  74589. get centerY(): number;
  74590. /** Gets or sets if control is Enabled*/
  74591. get isEnabled(): boolean;
  74592. set isEnabled(value: boolean);
  74593. /** Gets or sets background color of control if it's disabled*/
  74594. get disabledColor(): string;
  74595. set disabledColor(value: string);
  74596. /** Gets or sets front color of control if it's disabled*/
  74597. get disabledColorItem(): string;
  74598. set disabledColorItem(value: string);
  74599. /**
  74600. * Creates a new control
  74601. * @param name defines the name of the control
  74602. */
  74603. constructor(
  74604. /** defines the name of the control */
  74605. name?: string | undefined);
  74606. /** @hidden */
  74607. protected _getTypeName(): string;
  74608. /**
  74609. * Gets the first ascendant in the hierarchy of the given type
  74610. * @param className defines the required type
  74611. * @returns the ascendant or null if not found
  74612. */
  74613. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  74614. /** @hidden */
  74615. _resetFontCache(): void;
  74616. /**
  74617. * Determines if a container is an ascendant of the current control
  74618. * @param container defines the container to look for
  74619. * @returns true if the container is one of the ascendant of the control
  74620. */
  74621. isAscendant(container: Control): boolean;
  74622. /**
  74623. * Gets coordinates in local control space
  74624. * @param globalCoordinates defines the coordinates to transform
  74625. * @returns the new coordinates in local space
  74626. */
  74627. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74628. /**
  74629. * Gets coordinates in local control space
  74630. * @param globalCoordinates defines the coordinates to transform
  74631. * @param result defines the target vector2 where to store the result
  74632. * @returns the current control
  74633. */
  74634. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  74635. /**
  74636. * Gets coordinates in parent local control space
  74637. * @param globalCoordinates defines the coordinates to transform
  74638. * @returns the new coordinates in parent local space
  74639. */
  74640. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74641. /**
  74642. * Move the current control to a vector3 position projected onto the screen.
  74643. * @param position defines the target position
  74644. * @param scene defines the hosting scene
  74645. */
  74646. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  74647. /**
  74648. * Will store all controls that have this control as ascendant in a given array
  74649. * @param results defines the array where to store the descendants
  74650. * @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
  74651. * @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
  74652. */
  74653. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  74654. /**
  74655. * Will return all controls that have this control as ascendant
  74656. * @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
  74657. * @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
  74658. * @return all child controls
  74659. */
  74660. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74661. /**
  74662. * Link current control with a target mesh
  74663. * @param mesh defines the mesh to link with
  74664. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74665. */
  74666. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  74667. /** @hidden */
  74668. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  74669. /** @hidden */
  74670. _offsetLeft(offset: number): void;
  74671. /** @hidden */
  74672. _offsetTop(offset: number): void;
  74673. /** @hidden */
  74674. _markMatrixAsDirty(): void;
  74675. /** @hidden */
  74676. _flagDescendantsAsMatrixDirty(): void;
  74677. /** @hidden */
  74678. _intersectsRect(rect: Measure): boolean;
  74679. /** @hidden */
  74680. protected invalidateRect(): void;
  74681. /** @hidden */
  74682. _markAsDirty(force?: boolean): void;
  74683. /** @hidden */
  74684. _markAllAsDirty(): void;
  74685. /** @hidden */
  74686. _link(host: AdvancedDynamicTexture): void;
  74687. /** @hidden */
  74688. protected _transform(context?: CanvasRenderingContext2D): void;
  74689. /** @hidden */
  74690. _renderHighlight(context: CanvasRenderingContext2D): void;
  74691. /** @hidden */
  74692. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74693. /** @hidden */
  74694. protected _applyStates(context: CanvasRenderingContext2D): void;
  74695. /** @hidden */
  74696. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74697. /** @hidden */
  74698. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74699. protected _evaluateClippingState(parentMeasure: Measure): void;
  74700. /** @hidden */
  74701. _measure(): void;
  74702. /** @hidden */
  74703. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74704. /** @hidden */
  74705. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74706. /** @hidden */
  74707. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74708. /** @hidden */
  74709. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74710. private static _ClipMeasure;
  74711. private _tmpMeasureA;
  74712. private _clip;
  74713. /** @hidden */
  74714. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  74715. /** @hidden */
  74716. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74717. /**
  74718. * Tests if a given coordinates belong to the current control
  74719. * @param x defines x coordinate to test
  74720. * @param y defines y coordinate to test
  74721. * @returns true if the coordinates are inside the control
  74722. */
  74723. contains(x: number, y: number): boolean;
  74724. /** @hidden */
  74725. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74726. /** @hidden */
  74727. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74728. /** @hidden */
  74729. _onPointerEnter(target: Control): boolean;
  74730. /** @hidden */
  74731. _onPointerOut(target: Control, force?: boolean): void;
  74732. /** @hidden */
  74733. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74734. /** @hidden */
  74735. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74736. /** @hidden */
  74737. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74738. /** @hidden */
  74739. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  74740. /** @hidden */
  74741. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74742. private _prepareFont;
  74743. /** Releases associated resources */
  74744. dispose(): void;
  74745. private static _HORIZONTAL_ALIGNMENT_LEFT;
  74746. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  74747. private static _HORIZONTAL_ALIGNMENT_CENTER;
  74748. private static _VERTICAL_ALIGNMENT_TOP;
  74749. private static _VERTICAL_ALIGNMENT_BOTTOM;
  74750. private static _VERTICAL_ALIGNMENT_CENTER;
  74751. /** HORIZONTAL_ALIGNMENT_LEFT */
  74752. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  74753. /** HORIZONTAL_ALIGNMENT_RIGHT */
  74754. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  74755. /** HORIZONTAL_ALIGNMENT_CENTER */
  74756. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  74757. /** VERTICAL_ALIGNMENT_TOP */
  74758. static get VERTICAL_ALIGNMENT_TOP(): number;
  74759. /** VERTICAL_ALIGNMENT_BOTTOM */
  74760. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  74761. /** VERTICAL_ALIGNMENT_CENTER */
  74762. static get VERTICAL_ALIGNMENT_CENTER(): number;
  74763. private static _FontHeightSizes;
  74764. /** @hidden */
  74765. static _GetFontOffset(font: string): {
  74766. ascent: number;
  74767. height: number;
  74768. descent: number;
  74769. };
  74770. /**
  74771. * Creates a stack panel that can be used to render headers
  74772. * @param control defines the control to associate with the header
  74773. * @param text defines the text of the header
  74774. * @param size defines the size of the header
  74775. * @param options defines options used to configure the header
  74776. * @returns a new StackPanel
  74777. * @ignore
  74778. * @hidden
  74779. */
  74780. static AddHeader: (control: Control, text: string, size: string | number, options: {
  74781. isHorizontal: boolean;
  74782. controlFirst: boolean;
  74783. }) => any;
  74784. /** @hidden */
  74785. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  74786. }
  74787. }
  74788. declare module BABYLON.GUI {
  74789. /**
  74790. * Root class for 2D containers
  74791. * @see http://doc.babylonjs.com/how_to/gui#containers
  74792. */
  74793. export class Container extends Control {
  74794. name?: string | undefined;
  74795. /** @hidden */
  74796. _children: Control[];
  74797. /** @hidden */
  74798. protected _measureForChildren: Measure;
  74799. /** @hidden */
  74800. protected _background: string;
  74801. /** @hidden */
  74802. protected _adaptWidthToChildren: boolean;
  74803. /** @hidden */
  74804. protected _adaptHeightToChildren: boolean;
  74805. /**
  74806. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  74807. */
  74808. logLayoutCycleErrors: boolean;
  74809. /**
  74810. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  74811. */
  74812. maxLayoutCycle: number;
  74813. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  74814. get adaptHeightToChildren(): boolean;
  74815. set adaptHeightToChildren(value: boolean);
  74816. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  74817. get adaptWidthToChildren(): boolean;
  74818. set adaptWidthToChildren(value: boolean);
  74819. /** Gets or sets background color */
  74820. get background(): string;
  74821. set background(value: string);
  74822. /** Gets the list of children */
  74823. get children(): Control[];
  74824. /**
  74825. * Creates a new Container
  74826. * @param name defines the name of the container
  74827. */
  74828. constructor(name?: string | undefined);
  74829. protected _getTypeName(): string;
  74830. _flagDescendantsAsMatrixDirty(): void;
  74831. /**
  74832. * Gets a child using its name
  74833. * @param name defines the child name to look for
  74834. * @returns the child control if found
  74835. */
  74836. getChildByName(name: string): BABYLON.Nullable<Control>;
  74837. /**
  74838. * Gets a child using its type and its name
  74839. * @param name defines the child name to look for
  74840. * @param type defines the child type to look for
  74841. * @returns the child control if found
  74842. */
  74843. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  74844. /**
  74845. * Search for a specific control in children
  74846. * @param control defines the control to look for
  74847. * @returns true if the control is in child list
  74848. */
  74849. containsControl(control: Control): boolean;
  74850. /**
  74851. * Adds a new control to the current container
  74852. * @param control defines the control to add
  74853. * @returns the current container
  74854. */
  74855. addControl(control: BABYLON.Nullable<Control>): Container;
  74856. /**
  74857. * Removes all controls from the current container
  74858. * @returns the current container
  74859. */
  74860. clearControls(): Container;
  74861. /**
  74862. * Removes a control from the current container
  74863. * @param control defines the control to remove
  74864. * @returns the current container
  74865. */
  74866. removeControl(control: Control): Container;
  74867. /** @hidden */
  74868. _reOrderControl(control: Control): void;
  74869. /** @hidden */
  74870. _offsetLeft(offset: number): void;
  74871. /** @hidden */
  74872. _offsetTop(offset: number): void;
  74873. /** @hidden */
  74874. _markAllAsDirty(): void;
  74875. /** @hidden */
  74876. protected _localDraw(context: CanvasRenderingContext2D): void;
  74877. /** @hidden */
  74878. _link(host: AdvancedDynamicTexture): void;
  74879. /** @hidden */
  74880. protected _beforeLayout(): void;
  74881. /** @hidden */
  74882. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74883. /** @hidden */
  74884. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74885. protected _postMeasure(): void;
  74886. /** @hidden */
  74887. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  74888. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  74889. /** @hidden */
  74890. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74891. /** @hidden */
  74892. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74893. /** Releases associated resources */
  74894. dispose(): void;
  74895. }
  74896. }
  74897. declare module BABYLON.GUI {
  74898. /** Class used to create rectangle container */
  74899. export class Rectangle extends Container {
  74900. name?: string | undefined;
  74901. private _thickness;
  74902. private _cornerRadius;
  74903. /** Gets or sets border thickness */
  74904. get thickness(): number;
  74905. set thickness(value: number);
  74906. /** Gets or sets the corner radius angle */
  74907. get cornerRadius(): number;
  74908. set cornerRadius(value: number);
  74909. /**
  74910. * Creates a new Rectangle
  74911. * @param name defines the control name
  74912. */
  74913. constructor(name?: string | undefined);
  74914. protected _getTypeName(): string;
  74915. protected _localDraw(context: CanvasRenderingContext2D): void;
  74916. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74917. private _drawRoundedRect;
  74918. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74919. }
  74920. }
  74921. declare module BABYLON.GUI {
  74922. /**
  74923. * Enum that determines the text-wrapping mode to use.
  74924. */
  74925. export enum TextWrapping {
  74926. /**
  74927. * Clip the text when it's larger than Control.width; this is the default mode.
  74928. */
  74929. Clip = 0,
  74930. /**
  74931. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  74932. */
  74933. WordWrap = 1,
  74934. /**
  74935. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  74936. */
  74937. Ellipsis = 2
  74938. }
  74939. /**
  74940. * Class used to create text block control
  74941. */
  74942. export class TextBlock extends Control {
  74943. /**
  74944. * Defines the name of the control
  74945. */
  74946. name?: string | undefined;
  74947. private _text;
  74948. private _textWrapping;
  74949. private _textHorizontalAlignment;
  74950. private _textVerticalAlignment;
  74951. private _lines;
  74952. private _resizeToFit;
  74953. private _lineSpacing;
  74954. private _outlineWidth;
  74955. private _outlineColor;
  74956. /**
  74957. * An event triggered after the text is changed
  74958. */
  74959. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  74960. /**
  74961. * An event triggered after the text was broken up into lines
  74962. */
  74963. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  74964. /**
  74965. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  74966. */
  74967. get lines(): any[];
  74968. /**
  74969. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  74970. */
  74971. get resizeToFit(): boolean;
  74972. /**
  74973. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  74974. */
  74975. set resizeToFit(value: boolean);
  74976. /**
  74977. * Gets or sets a boolean indicating if text must be wrapped
  74978. */
  74979. get textWrapping(): TextWrapping | boolean;
  74980. /**
  74981. * Gets or sets a boolean indicating if text must be wrapped
  74982. */
  74983. set textWrapping(value: TextWrapping | boolean);
  74984. /**
  74985. * Gets or sets text to display
  74986. */
  74987. get text(): string;
  74988. /**
  74989. * Gets or sets text to display
  74990. */
  74991. set text(value: string);
  74992. /**
  74993. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74994. */
  74995. get textHorizontalAlignment(): number;
  74996. /**
  74997. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74998. */
  74999. set textHorizontalAlignment(value: number);
  75000. /**
  75001. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75002. */
  75003. get textVerticalAlignment(): number;
  75004. /**
  75005. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75006. */
  75007. set textVerticalAlignment(value: number);
  75008. /**
  75009. * Gets or sets line spacing value
  75010. */
  75011. set lineSpacing(value: string | number);
  75012. /**
  75013. * Gets or sets line spacing value
  75014. */
  75015. get lineSpacing(): string | number;
  75016. /**
  75017. * Gets or sets outlineWidth of the text to display
  75018. */
  75019. get outlineWidth(): number;
  75020. /**
  75021. * Gets or sets outlineWidth of the text to display
  75022. */
  75023. set outlineWidth(value: number);
  75024. /**
  75025. * Gets or sets outlineColor of the text to display
  75026. */
  75027. get outlineColor(): string;
  75028. /**
  75029. * Gets or sets outlineColor of the text to display
  75030. */
  75031. set outlineColor(value: string);
  75032. /**
  75033. * Creates a new TextBlock object
  75034. * @param name defines the name of the control
  75035. * @param text defines the text to display (emptry string by default)
  75036. */
  75037. constructor(
  75038. /**
  75039. * Defines the name of the control
  75040. */
  75041. name?: string | undefined, text?: string);
  75042. protected _getTypeName(): string;
  75043. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75044. private _drawText;
  75045. /** @hidden */
  75046. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75047. protected _applyStates(context: CanvasRenderingContext2D): void;
  75048. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75049. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75050. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75051. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75052. protected _renderLines(context: CanvasRenderingContext2D): void;
  75053. /**
  75054. * Given a width constraint applied on the text block, find the expected height
  75055. * @returns expected height
  75056. */
  75057. computeExpectedHeight(): number;
  75058. dispose(): void;
  75059. }
  75060. }
  75061. declare module BABYLON.GUI {
  75062. /**
  75063. * Class used to create 2D images
  75064. */
  75065. export class Image extends Control {
  75066. name?: string | undefined;
  75067. private _workingCanvas;
  75068. private _domImage;
  75069. private _imageWidth;
  75070. private _imageHeight;
  75071. private _loaded;
  75072. private _stretch;
  75073. private _source;
  75074. private _autoScale;
  75075. private _sourceLeft;
  75076. private _sourceTop;
  75077. private _sourceWidth;
  75078. private _sourceHeight;
  75079. private _svgAttributesComputationCompleted;
  75080. private _isSVG;
  75081. private _cellWidth;
  75082. private _cellHeight;
  75083. private _cellId;
  75084. private _populateNinePatchSlicesFromImage;
  75085. private _sliceLeft;
  75086. private _sliceRight;
  75087. private _sliceTop;
  75088. private _sliceBottom;
  75089. private _detectPointerOnOpaqueOnly;
  75090. /**
  75091. * BABYLON.Observable notified when the content is loaded
  75092. */
  75093. onImageLoadedObservable: BABYLON.Observable<Image>;
  75094. /**
  75095. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75096. */
  75097. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75098. /**
  75099. * Gets a boolean indicating that the content is loaded
  75100. */
  75101. get isLoaded(): boolean;
  75102. /**
  75103. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75104. */
  75105. get populateNinePatchSlicesFromImage(): boolean;
  75106. set populateNinePatchSlicesFromImage(value: boolean);
  75107. /**
  75108. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75109. * Beware using this as this will comsume more memory as the image has to be stored twice
  75110. */
  75111. get detectPointerOnOpaqueOnly(): boolean;
  75112. set detectPointerOnOpaqueOnly(value: boolean);
  75113. /**
  75114. * Gets or sets the left value for slicing (9-patch)
  75115. */
  75116. get sliceLeft(): number;
  75117. set sliceLeft(value: number);
  75118. /**
  75119. * Gets or sets the right value for slicing (9-patch)
  75120. */
  75121. get sliceRight(): number;
  75122. set sliceRight(value: number);
  75123. /**
  75124. * Gets or sets the top value for slicing (9-patch)
  75125. */
  75126. get sliceTop(): number;
  75127. set sliceTop(value: number);
  75128. /**
  75129. * Gets or sets the bottom value for slicing (9-patch)
  75130. */
  75131. get sliceBottom(): number;
  75132. set sliceBottom(value: number);
  75133. /**
  75134. * Gets or sets the left coordinate in the source image
  75135. */
  75136. get sourceLeft(): number;
  75137. set sourceLeft(value: number);
  75138. /**
  75139. * Gets or sets the top coordinate in the source image
  75140. */
  75141. get sourceTop(): number;
  75142. set sourceTop(value: number);
  75143. /**
  75144. * Gets or sets the width to capture in the source image
  75145. */
  75146. get sourceWidth(): number;
  75147. set sourceWidth(value: number);
  75148. /**
  75149. * Gets or sets the height to capture in the source image
  75150. */
  75151. get sourceHeight(): number;
  75152. set sourceHeight(value: number);
  75153. /** Indicates if the format of the image is SVG */
  75154. get isSVG(): boolean;
  75155. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75156. get svgAttributesComputationCompleted(): boolean;
  75157. /**
  75158. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75159. * @see http://doc.babylonjs.com/how_to/gui#image
  75160. */
  75161. get autoScale(): boolean;
  75162. set autoScale(value: boolean);
  75163. /** Gets or sets the streching mode used by the image */
  75164. get stretch(): number;
  75165. set stretch(value: number);
  75166. /** @hidden */
  75167. _rotate90(n: number, preserveProperties?: boolean): Image;
  75168. private _handleRotationForSVGImage;
  75169. private _rotate90SourceProperties;
  75170. /**
  75171. * Gets or sets the internal DOM image used to render the control
  75172. */
  75173. set domImage(value: HTMLImageElement);
  75174. get domImage(): HTMLImageElement;
  75175. private _onImageLoaded;
  75176. private _extractNinePatchSliceDataFromImage;
  75177. /**
  75178. * Gets or sets image source url
  75179. */
  75180. set source(value: BABYLON.Nullable<string>);
  75181. /**
  75182. * Checks for svg document with icon id present
  75183. */
  75184. private _svgCheck;
  75185. /**
  75186. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75187. * given external svg file and icon id
  75188. */
  75189. private _getSVGAttribs;
  75190. /**
  75191. * Gets or sets the cell width to use when animation sheet is enabled
  75192. * @see http://doc.babylonjs.com/how_to/gui#image
  75193. */
  75194. get cellWidth(): number;
  75195. set cellWidth(value: number);
  75196. /**
  75197. * Gets or sets the cell height to use when animation sheet is enabled
  75198. * @see http://doc.babylonjs.com/how_to/gui#image
  75199. */
  75200. get cellHeight(): number;
  75201. set cellHeight(value: number);
  75202. /**
  75203. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75204. * @see http://doc.babylonjs.com/how_to/gui#image
  75205. */
  75206. get cellId(): number;
  75207. set cellId(value: number);
  75208. /**
  75209. * Creates a new Image
  75210. * @param name defines the control name
  75211. * @param url defines the image url
  75212. */
  75213. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75214. /**
  75215. * Tests if a given coordinates belong to the current control
  75216. * @param x defines x coordinate to test
  75217. * @param y defines y coordinate to test
  75218. * @returns true if the coordinates are inside the control
  75219. */
  75220. contains(x: number, y: number): boolean;
  75221. protected _getTypeName(): string;
  75222. /** Force the control to synchronize with its content */
  75223. synchronizeSizeWithContent(): void;
  75224. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75225. private _prepareWorkingCanvasForOpaqueDetection;
  75226. private _drawImage;
  75227. _draw(context: CanvasRenderingContext2D): void;
  75228. private _renderCornerPatch;
  75229. private _renderNinePatch;
  75230. dispose(): void;
  75231. /** STRETCH_NONE */
  75232. static readonly STRETCH_NONE: number;
  75233. /** STRETCH_FILL */
  75234. static readonly STRETCH_FILL: number;
  75235. /** STRETCH_UNIFORM */
  75236. static readonly STRETCH_UNIFORM: number;
  75237. /** STRETCH_EXTEND */
  75238. static readonly STRETCH_EXTEND: number;
  75239. /** NINE_PATCH */
  75240. static readonly STRETCH_NINE_PATCH: number;
  75241. }
  75242. }
  75243. declare module BABYLON.GUI {
  75244. /**
  75245. * Class used to create 2D buttons
  75246. */
  75247. export class Button extends Rectangle {
  75248. name?: string | undefined;
  75249. /**
  75250. * Function called to generate a pointer enter animation
  75251. */
  75252. pointerEnterAnimation: () => void;
  75253. /**
  75254. * Function called to generate a pointer out animation
  75255. */
  75256. pointerOutAnimation: () => void;
  75257. /**
  75258. * Function called to generate a pointer down animation
  75259. */
  75260. pointerDownAnimation: () => void;
  75261. /**
  75262. * Function called to generate a pointer up animation
  75263. */
  75264. pointerUpAnimation: () => void;
  75265. /**
  75266. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75267. */
  75268. delegatePickingToChildren: boolean;
  75269. private _image;
  75270. /**
  75271. * Returns the image part of the button (if any)
  75272. */
  75273. get image(): BABYLON.Nullable<Image>;
  75274. private _textBlock;
  75275. /**
  75276. * Returns the image part of the button (if any)
  75277. */
  75278. get textBlock(): BABYLON.Nullable<TextBlock>;
  75279. /**
  75280. * Creates a new Button
  75281. * @param name defines the name of the button
  75282. */
  75283. constructor(name?: string | undefined);
  75284. protected _getTypeName(): string;
  75285. /** @hidden */
  75286. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75287. /** @hidden */
  75288. _onPointerEnter(target: Control): boolean;
  75289. /** @hidden */
  75290. _onPointerOut(target: Control, force?: boolean): void;
  75291. /** @hidden */
  75292. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75293. /** @hidden */
  75294. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75295. /**
  75296. * Creates a new button made with an image and a text
  75297. * @param name defines the name of the button
  75298. * @param text defines the text of the button
  75299. * @param imageUrl defines the url of the image
  75300. * @returns a new Button
  75301. */
  75302. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75303. /**
  75304. * Creates a new button made with an image
  75305. * @param name defines the name of the button
  75306. * @param imageUrl defines the url of the image
  75307. * @returns a new Button
  75308. */
  75309. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75310. /**
  75311. * Creates a new button made with a text
  75312. * @param name defines the name of the button
  75313. * @param text defines the text of the button
  75314. * @returns a new Button
  75315. */
  75316. static CreateSimpleButton(name: string, text: string): Button;
  75317. /**
  75318. * Creates a new button made with an image and a centered text
  75319. * @param name defines the name of the button
  75320. * @param text defines the text of the button
  75321. * @param imageUrl defines the url of the image
  75322. * @returns a new Button
  75323. */
  75324. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75325. }
  75326. }
  75327. declare module BABYLON.GUI {
  75328. /**
  75329. * Class used to create a 2D stack panel container
  75330. */
  75331. export class StackPanel extends Container {
  75332. name?: string | undefined;
  75333. private _isVertical;
  75334. private _manualWidth;
  75335. private _manualHeight;
  75336. private _doNotTrackManualChanges;
  75337. /**
  75338. * Gets or sets a boolean indicating that layou warnings should be ignored
  75339. */
  75340. ignoreLayoutWarnings: boolean;
  75341. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75342. get isVertical(): boolean;
  75343. set isVertical(value: boolean);
  75344. /**
  75345. * Gets or sets panel width.
  75346. * This value should not be set when in horizontal mode as it will be computed automatically
  75347. */
  75348. set width(value: string | number);
  75349. get width(): string | number;
  75350. /**
  75351. * Gets or sets panel height.
  75352. * This value should not be set when in vertical mode as it will be computed automatically
  75353. */
  75354. set height(value: string | number);
  75355. get height(): string | number;
  75356. /**
  75357. * Creates a new StackPanel
  75358. * @param name defines control name
  75359. */
  75360. constructor(name?: string | undefined);
  75361. protected _getTypeName(): string;
  75362. /** @hidden */
  75363. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75364. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75365. protected _postMeasure(): void;
  75366. }
  75367. }
  75368. declare module BABYLON.GUI {
  75369. /**
  75370. * Class used to represent a 2D checkbox
  75371. */
  75372. export class Checkbox extends Control {
  75373. name?: string | undefined;
  75374. private _isChecked;
  75375. private _background;
  75376. private _checkSizeRatio;
  75377. private _thickness;
  75378. /** Gets or sets border thickness */
  75379. get thickness(): number;
  75380. set thickness(value: number);
  75381. /**
  75382. * BABYLON.Observable raised when isChecked property changes
  75383. */
  75384. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75385. /** Gets or sets a value indicating the ratio between overall size and check size */
  75386. get checkSizeRatio(): number;
  75387. set checkSizeRatio(value: number);
  75388. /** Gets or sets background color */
  75389. get background(): string;
  75390. set background(value: string);
  75391. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75392. get isChecked(): boolean;
  75393. set isChecked(value: boolean);
  75394. /**
  75395. * Creates a new CheckBox
  75396. * @param name defines the control name
  75397. */
  75398. constructor(name?: string | undefined);
  75399. protected _getTypeName(): string;
  75400. /** @hidden */
  75401. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75402. /** @hidden */
  75403. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75404. /**
  75405. * Utility function to easily create a checkbox with a header
  75406. * @param title defines the label to use for the header
  75407. * @param onValueChanged defines the callback to call when value changes
  75408. * @returns a StackPanel containing the checkbox and a textBlock
  75409. */
  75410. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  75411. }
  75412. }
  75413. declare module BABYLON.GUI {
  75414. /**
  75415. * Class used to store key control properties
  75416. */
  75417. export class KeyPropertySet {
  75418. /** Width */
  75419. width?: string;
  75420. /** Height */
  75421. height?: string;
  75422. /** Left padding */
  75423. paddingLeft?: string;
  75424. /** Right padding */
  75425. paddingRight?: string;
  75426. /** Top padding */
  75427. paddingTop?: string;
  75428. /** Bottom padding */
  75429. paddingBottom?: string;
  75430. /** Foreground color */
  75431. color?: string;
  75432. /** Background color */
  75433. background?: string;
  75434. }
  75435. /**
  75436. * Class used to create virtual keyboard
  75437. */
  75438. export class VirtualKeyboard extends StackPanel {
  75439. /** BABYLON.Observable raised when a key is pressed */
  75440. onKeyPressObservable: BABYLON.Observable<string>;
  75441. /** Gets or sets default key button width */
  75442. defaultButtonWidth: string;
  75443. /** Gets or sets default key button height */
  75444. defaultButtonHeight: string;
  75445. /** Gets or sets default key button left padding */
  75446. defaultButtonPaddingLeft: string;
  75447. /** Gets or sets default key button right padding */
  75448. defaultButtonPaddingRight: string;
  75449. /** Gets or sets default key button top padding */
  75450. defaultButtonPaddingTop: string;
  75451. /** Gets or sets default key button bottom padding */
  75452. defaultButtonPaddingBottom: string;
  75453. /** Gets or sets default key button foreground color */
  75454. defaultButtonColor: string;
  75455. /** Gets or sets default key button background color */
  75456. defaultButtonBackground: string;
  75457. /** Gets or sets shift button foreground color */
  75458. shiftButtonColor: string;
  75459. /** Gets or sets shift button thickness*/
  75460. selectedShiftThickness: number;
  75461. /** Gets shift key state */
  75462. shiftState: number;
  75463. protected _getTypeName(): string;
  75464. private _createKey;
  75465. /**
  75466. * Adds a new row of keys
  75467. * @param keys defines the list of keys to add
  75468. * @param propertySets defines the associated property sets
  75469. */
  75470. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  75471. /**
  75472. * Set the shift key to a specific state
  75473. * @param shiftState defines the new shift state
  75474. */
  75475. applyShiftState(shiftState: number): void;
  75476. private _currentlyConnectedInputText;
  75477. private _connectedInputTexts;
  75478. private _onKeyPressObserver;
  75479. /** Gets the input text control currently attached to the keyboard */
  75480. get connectedInputText(): BABYLON.Nullable<InputText>;
  75481. /**
  75482. * Connects the keyboard with an input text control
  75483. *
  75484. * @param input defines the target control
  75485. */
  75486. connect(input: InputText): void;
  75487. /**
  75488. * Disconnects the keyboard from connected InputText controls
  75489. *
  75490. * @param input optionally defines a target control, otherwise all are disconnected
  75491. */
  75492. disconnect(input?: InputText): void;
  75493. private _removeConnectedInputObservables;
  75494. /**
  75495. * Release all resources
  75496. */
  75497. dispose(): void;
  75498. /**
  75499. * Creates a new keyboard using a default layout
  75500. *
  75501. * @param name defines control name
  75502. * @returns a new VirtualKeyboard
  75503. */
  75504. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  75505. }
  75506. }
  75507. declare module BABYLON.GUI {
  75508. /**
  75509. * Class used to create input text control
  75510. */
  75511. export class InputText extends Control implements IFocusableControl {
  75512. name?: string | undefined;
  75513. private _text;
  75514. private _placeholderText;
  75515. private _background;
  75516. private _focusedBackground;
  75517. private _focusedColor;
  75518. private _placeholderColor;
  75519. private _thickness;
  75520. private _margin;
  75521. private _autoStretchWidth;
  75522. private _maxWidth;
  75523. private _isFocused;
  75524. private _blinkTimeout;
  75525. private _blinkIsEven;
  75526. private _cursorOffset;
  75527. private _scrollLeft;
  75528. private _textWidth;
  75529. private _clickedCoordinate;
  75530. private _deadKey;
  75531. private _addKey;
  75532. private _currentKey;
  75533. private _isTextHighlightOn;
  75534. private _textHighlightColor;
  75535. private _highligherOpacity;
  75536. private _highlightedText;
  75537. private _startHighlightIndex;
  75538. private _endHighlightIndex;
  75539. private _cursorIndex;
  75540. private _onFocusSelectAll;
  75541. private _isPointerDown;
  75542. private _onClipboardObserver;
  75543. private _onPointerDblTapObserver;
  75544. /** @hidden */
  75545. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  75546. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  75547. promptMessage: string;
  75548. /** Force disable prompt on mobile device */
  75549. disableMobilePrompt: boolean;
  75550. /** BABYLON.Observable raised when the text changes */
  75551. onTextChangedObservable: BABYLON.Observable<InputText>;
  75552. /** BABYLON.Observable raised just before an entered character is to be added */
  75553. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  75554. /** BABYLON.Observable raised when the control gets the focus */
  75555. onFocusObservable: BABYLON.Observable<InputText>;
  75556. /** BABYLON.Observable raised when the control loses the focus */
  75557. onBlurObservable: BABYLON.Observable<InputText>;
  75558. /**Observable raised when the text is highlighted */
  75559. onTextHighlightObservable: BABYLON.Observable<InputText>;
  75560. /**Observable raised when copy event is triggered */
  75561. onTextCopyObservable: BABYLON.Observable<InputText>;
  75562. /** BABYLON.Observable raised when cut event is triggered */
  75563. onTextCutObservable: BABYLON.Observable<InputText>;
  75564. /** BABYLON.Observable raised when paste event is triggered */
  75565. onTextPasteObservable: BABYLON.Observable<InputText>;
  75566. /** BABYLON.Observable raised when a key event was processed */
  75567. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  75568. /** Gets or sets the maximum width allowed by the control */
  75569. get maxWidth(): string | number;
  75570. /** Gets the maximum width allowed by the control in pixels */
  75571. get maxWidthInPixels(): number;
  75572. set maxWidth(value: string | number);
  75573. /** Gets or sets the text highlighter transparency; default: 0.4 */
  75574. get highligherOpacity(): number;
  75575. set highligherOpacity(value: number);
  75576. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  75577. get onFocusSelectAll(): boolean;
  75578. set onFocusSelectAll(value: boolean);
  75579. /** Gets or sets the text hightlight color */
  75580. get textHighlightColor(): string;
  75581. set textHighlightColor(value: string);
  75582. /** Gets or sets control margin */
  75583. get margin(): string;
  75584. /** Gets control margin in pixels */
  75585. get marginInPixels(): number;
  75586. set margin(value: string);
  75587. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  75588. get autoStretchWidth(): boolean;
  75589. set autoStretchWidth(value: boolean);
  75590. /** Gets or sets border thickness */
  75591. get thickness(): number;
  75592. set thickness(value: number);
  75593. /** Gets or sets the background color when focused */
  75594. get focusedBackground(): string;
  75595. set focusedBackground(value: string);
  75596. /** Gets or sets the background color when focused */
  75597. get focusedColor(): string;
  75598. set focusedColor(value: string);
  75599. /** Gets or sets the background color */
  75600. get background(): string;
  75601. set background(value: string);
  75602. /** Gets or sets the placeholder color */
  75603. get placeholderColor(): string;
  75604. set placeholderColor(value: string);
  75605. /** Gets or sets the text displayed when the control is empty */
  75606. get placeholderText(): string;
  75607. set placeholderText(value: string);
  75608. /** Gets or sets the dead key flag */
  75609. get deadKey(): boolean;
  75610. set deadKey(flag: boolean);
  75611. /** Gets or sets the highlight text */
  75612. get highlightedText(): string;
  75613. set highlightedText(text: string);
  75614. /** Gets or sets if the current key should be added */
  75615. get addKey(): boolean;
  75616. set addKey(flag: boolean);
  75617. /** Gets or sets the value of the current key being entered */
  75618. get currentKey(): string;
  75619. set currentKey(key: string);
  75620. /** Gets or sets the text displayed in the control */
  75621. get text(): string;
  75622. set text(value: string);
  75623. /** Gets or sets control width */
  75624. get width(): string | number;
  75625. set width(value: string | number);
  75626. /**
  75627. * Creates a new InputText
  75628. * @param name defines the control name
  75629. * @param text defines the text of the control
  75630. */
  75631. constructor(name?: string | undefined, text?: string);
  75632. /** @hidden */
  75633. onBlur(): void;
  75634. /** @hidden */
  75635. onFocus(): void;
  75636. protected _getTypeName(): string;
  75637. /**
  75638. * Function called to get the list of controls that should not steal the focus from this control
  75639. * @returns an array of controls
  75640. */
  75641. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75642. /** @hidden */
  75643. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  75644. /** @hidden */
  75645. private _updateValueFromCursorIndex;
  75646. /** @hidden */
  75647. private _processDblClick;
  75648. /** @hidden */
  75649. private _selectAllText;
  75650. /**
  75651. * Handles the keyboard event
  75652. * @param evt Defines the KeyboardEvent
  75653. */
  75654. processKeyboard(evt: KeyboardEvent): void;
  75655. /** @hidden */
  75656. private _onCopyText;
  75657. /** @hidden */
  75658. private _onCutText;
  75659. /** @hidden */
  75660. private _onPasteText;
  75661. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75662. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75663. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75664. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75665. protected _beforeRenderText(text: string): string;
  75666. dispose(): void;
  75667. }
  75668. }
  75669. declare module BABYLON.GUI {
  75670. /**
  75671. * Class used to create a 2D grid container
  75672. */
  75673. export class Grid extends Container {
  75674. name?: string | undefined;
  75675. private _rowDefinitions;
  75676. private _columnDefinitions;
  75677. private _cells;
  75678. private _childControls;
  75679. /**
  75680. * Gets the number of columns
  75681. */
  75682. get columnCount(): number;
  75683. /**
  75684. * Gets the number of rows
  75685. */
  75686. get rowCount(): number;
  75687. /** Gets the list of children */
  75688. get children(): Control[];
  75689. /** Gets the list of cells (e.g. the containers) */
  75690. get cells(): {
  75691. [key: string]: Container;
  75692. };
  75693. /**
  75694. * Gets the definition of a specific row
  75695. * @param index defines the index of the row
  75696. * @returns the row definition
  75697. */
  75698. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75699. /**
  75700. * Gets the definition of a specific column
  75701. * @param index defines the index of the column
  75702. * @returns the column definition
  75703. */
  75704. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75705. /**
  75706. * Adds a new row to the grid
  75707. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75708. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  75709. * @returns the current grid
  75710. */
  75711. addRowDefinition(height: number, isPixel?: boolean): Grid;
  75712. /**
  75713. * Adds a new column to the grid
  75714. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75715. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75716. * @returns the current grid
  75717. */
  75718. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  75719. /**
  75720. * Update a row definition
  75721. * @param index defines the index of the row to update
  75722. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75723. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  75724. * @returns the current grid
  75725. */
  75726. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  75727. /**
  75728. * Update a column definition
  75729. * @param index defines the index of the column to update
  75730. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75731. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75732. * @returns the current grid
  75733. */
  75734. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  75735. /**
  75736. * Gets the list of children stored in a specific cell
  75737. * @param row defines the row to check
  75738. * @param column defines the column to check
  75739. * @returns the list of controls
  75740. */
  75741. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  75742. /**
  75743. * Gets a string representing the child cell info (row x column)
  75744. * @param child defines the control to get info from
  75745. * @returns a string containing the child cell info (row x column)
  75746. */
  75747. getChildCellInfo(child: Control): string;
  75748. private _removeCell;
  75749. private _offsetCell;
  75750. /**
  75751. * Remove a column definition at specified index
  75752. * @param index defines the index of the column to remove
  75753. * @returns the current grid
  75754. */
  75755. removeColumnDefinition(index: number): Grid;
  75756. /**
  75757. * Remove a row definition at specified index
  75758. * @param index defines the index of the row to remove
  75759. * @returns the current grid
  75760. */
  75761. removeRowDefinition(index: number): Grid;
  75762. /**
  75763. * Adds a new control to the current grid
  75764. * @param control defines the control to add
  75765. * @param row defines the row where to add the control (0 by default)
  75766. * @param column defines the column where to add the control (0 by default)
  75767. * @returns the current grid
  75768. */
  75769. addControl(control: Control, row?: number, column?: number): Grid;
  75770. /**
  75771. * Removes a control from the current container
  75772. * @param control defines the control to remove
  75773. * @returns the current container
  75774. */
  75775. removeControl(control: Control): Container;
  75776. /**
  75777. * Creates a new Grid
  75778. * @param name defines control name
  75779. */
  75780. constructor(name?: string | undefined);
  75781. protected _getTypeName(): string;
  75782. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  75783. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75784. _flagDescendantsAsMatrixDirty(): void;
  75785. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75786. /** Releases associated resources */
  75787. dispose(): void;
  75788. }
  75789. }
  75790. declare module BABYLON.GUI {
  75791. /** Class used to create color pickers */
  75792. export class ColorPicker extends Control {
  75793. name?: string | undefined;
  75794. private static _Epsilon;
  75795. private _colorWheelCanvas;
  75796. private _value;
  75797. private _tmpColor;
  75798. private _pointerStartedOnSquare;
  75799. private _pointerStartedOnWheel;
  75800. private _squareLeft;
  75801. private _squareTop;
  75802. private _squareSize;
  75803. private _h;
  75804. private _s;
  75805. private _v;
  75806. private _lastPointerDownID;
  75807. /**
  75808. * BABYLON.Observable raised when the value changes
  75809. */
  75810. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  75811. /** Gets or sets the color of the color picker */
  75812. get value(): BABYLON.Color3;
  75813. set value(value: BABYLON.Color3);
  75814. /**
  75815. * Gets or sets control width
  75816. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75817. */
  75818. get width(): string | number;
  75819. set width(value: string | number);
  75820. /**
  75821. * Gets or sets control height
  75822. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75823. */
  75824. get height(): string | number;
  75825. /** Gets or sets control height */
  75826. set height(value: string | number);
  75827. /** Gets or sets control size */
  75828. get size(): string | number;
  75829. set size(value: string | number);
  75830. /**
  75831. * Creates a new ColorPicker
  75832. * @param name defines the control name
  75833. */
  75834. constructor(name?: string | undefined);
  75835. protected _getTypeName(): string;
  75836. /** @hidden */
  75837. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75838. private _updateSquareProps;
  75839. private _drawGradientSquare;
  75840. private _drawCircle;
  75841. private _createColorWheelCanvas;
  75842. /** @hidden */
  75843. _draw(context: CanvasRenderingContext2D): void;
  75844. private _pointerIsDown;
  75845. private _updateValueFromPointer;
  75846. private _isPointOnSquare;
  75847. private _isPointOnWheel;
  75848. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75849. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75850. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75851. /**
  75852. * This function expands the color picker by creating a color picker dialog with manual
  75853. * color value input and the ability to save colors into an array to be used later in
  75854. * subsequent launches of the dialogue.
  75855. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  75856. * @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.
  75857. * @returns picked color as a hex string and the saved colors array as hex strings.
  75858. */
  75859. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  75860. pickerWidth?: string;
  75861. pickerHeight?: string;
  75862. headerHeight?: string;
  75863. lastColor?: string;
  75864. swatchLimit?: number;
  75865. numSwatchesPerLine?: number;
  75866. savedColors?: Array<string>;
  75867. }): Promise<{
  75868. savedColors?: string[];
  75869. pickedColor: string;
  75870. }>;
  75871. }
  75872. }
  75873. declare module BABYLON.GUI {
  75874. /** Class used to create 2D ellipse containers */
  75875. export class Ellipse extends Container {
  75876. name?: string | undefined;
  75877. private _thickness;
  75878. /** Gets or sets border thickness */
  75879. get thickness(): number;
  75880. set thickness(value: number);
  75881. /**
  75882. * Creates a new Ellipse
  75883. * @param name defines the control name
  75884. */
  75885. constructor(name?: string | undefined);
  75886. protected _getTypeName(): string;
  75887. protected _localDraw(context: CanvasRenderingContext2D): void;
  75888. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75889. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75890. }
  75891. }
  75892. declare module BABYLON.GUI {
  75893. /**
  75894. * Class used to create a password control
  75895. */
  75896. export class InputPassword extends InputText {
  75897. protected _beforeRenderText(text: string): string;
  75898. }
  75899. }
  75900. declare module BABYLON.GUI {
  75901. /** Class used to render 2D lines */
  75902. export class Line extends Control {
  75903. name?: string | undefined;
  75904. private _lineWidth;
  75905. private _x1;
  75906. private _y1;
  75907. private _x2;
  75908. private _y2;
  75909. private _dash;
  75910. private _connectedControl;
  75911. private _connectedControlDirtyObserver;
  75912. /** Gets or sets the dash pattern */
  75913. get dash(): Array<number>;
  75914. set dash(value: Array<number>);
  75915. /** Gets or sets the control connected with the line end */
  75916. get connectedControl(): Control;
  75917. set connectedControl(value: Control);
  75918. /** Gets or sets start coordinates on X axis */
  75919. get x1(): string | number;
  75920. set x1(value: string | number);
  75921. /** Gets or sets start coordinates on Y axis */
  75922. get y1(): string | number;
  75923. set y1(value: string | number);
  75924. /** Gets or sets end coordinates on X axis */
  75925. get x2(): string | number;
  75926. set x2(value: string | number);
  75927. /** Gets or sets end coordinates on Y axis */
  75928. get y2(): string | number;
  75929. set y2(value: string | number);
  75930. /** Gets or sets line width */
  75931. get lineWidth(): number;
  75932. set lineWidth(value: number);
  75933. /** Gets or sets horizontal alignment */
  75934. set horizontalAlignment(value: number);
  75935. /** Gets or sets vertical alignment */
  75936. set verticalAlignment(value: number);
  75937. private get _effectiveX2();
  75938. private get _effectiveY2();
  75939. /**
  75940. * Creates a new Line
  75941. * @param name defines the control name
  75942. */
  75943. constructor(name?: string | undefined);
  75944. protected _getTypeName(): string;
  75945. _draw(context: CanvasRenderingContext2D): void;
  75946. _measure(): void;
  75947. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75948. /**
  75949. * Move one end of the line given 3D cartesian coordinates.
  75950. * @param position Targeted world position
  75951. * @param scene BABYLON.Scene
  75952. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  75953. */
  75954. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  75955. /**
  75956. * Move one end of the line to a position in screen absolute space.
  75957. * @param projectedPosition Position in screen absolute space (X, Y)
  75958. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  75959. */
  75960. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  75961. }
  75962. }
  75963. declare module BABYLON.GUI {
  75964. /**
  75965. * Class used to store a point for a MultiLine object.
  75966. * The point can be pure 2D coordinates, a mesh or a control
  75967. */
  75968. export class MultiLinePoint {
  75969. private _multiLine;
  75970. private _x;
  75971. private _y;
  75972. private _control;
  75973. private _mesh;
  75974. private _controlObserver;
  75975. private _meshObserver;
  75976. /** @hidden */
  75977. _point: BABYLON.Vector2;
  75978. /**
  75979. * Creates a new MultiLinePoint
  75980. * @param multiLine defines the source MultiLine object
  75981. */
  75982. constructor(multiLine: MultiLine);
  75983. /** Gets or sets x coordinate */
  75984. get x(): string | number;
  75985. set x(value: string | number);
  75986. /** Gets or sets y coordinate */
  75987. get y(): string | number;
  75988. set y(value: string | number);
  75989. /** Gets or sets the control associated with this point */
  75990. get control(): BABYLON.Nullable<Control>;
  75991. set control(value: BABYLON.Nullable<Control>);
  75992. /** Gets or sets the mesh associated with this point */
  75993. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75994. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  75995. /** Resets links */
  75996. resetLinks(): void;
  75997. /**
  75998. * Gets a translation vector
  75999. * @returns the translation vector
  76000. */
  76001. translate(): BABYLON.Vector2;
  76002. private _translatePoint;
  76003. /** Release associated resources */
  76004. dispose(): void;
  76005. }
  76006. }
  76007. declare module BABYLON.GUI {
  76008. /**
  76009. * Class used to create multi line control
  76010. */
  76011. export class MultiLine extends Control {
  76012. name?: string | undefined;
  76013. private _lineWidth;
  76014. private _dash;
  76015. private _points;
  76016. private _minX;
  76017. private _minY;
  76018. private _maxX;
  76019. private _maxY;
  76020. /**
  76021. * Creates a new MultiLine
  76022. * @param name defines the control name
  76023. */
  76024. constructor(name?: string | undefined);
  76025. /** Gets or sets dash pattern */
  76026. get dash(): Array<number>;
  76027. set dash(value: Array<number>);
  76028. /**
  76029. * Gets point stored at specified index
  76030. * @param index defines the index to look for
  76031. * @returns the requested point if found
  76032. */
  76033. getAt(index: number): MultiLinePoint;
  76034. /** Function called when a point is updated */
  76035. onPointUpdate: () => void;
  76036. /**
  76037. * Adds new points to the point collection
  76038. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76039. * @returns the list of created MultiLinePoint
  76040. */
  76041. add(...items: (AbstractMesh | Control | {
  76042. x: string | number;
  76043. y: string | number;
  76044. })[]): MultiLinePoint[];
  76045. /**
  76046. * Adds a new point to the point collection
  76047. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76048. * @returns the created MultiLinePoint
  76049. */
  76050. push(item?: (AbstractMesh | Control | {
  76051. x: string | number;
  76052. y: string | number;
  76053. })): MultiLinePoint;
  76054. /**
  76055. * Remove a specific value or point from the active point collection
  76056. * @param value defines the value or point to remove
  76057. */
  76058. remove(value: number | MultiLinePoint): void;
  76059. /**
  76060. * Resets this object to initial state (no point)
  76061. */
  76062. reset(): void;
  76063. /**
  76064. * Resets all links
  76065. */
  76066. resetLinks(): void;
  76067. /** Gets or sets line width */
  76068. get lineWidth(): number;
  76069. set lineWidth(value: number);
  76070. set horizontalAlignment(value: number);
  76071. set verticalAlignment(value: number);
  76072. protected _getTypeName(): string;
  76073. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76074. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76075. _measure(): void;
  76076. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76077. dispose(): void;
  76078. }
  76079. }
  76080. declare module BABYLON.GUI {
  76081. /**
  76082. * Class used to create radio button controls
  76083. */
  76084. export class RadioButton extends Control {
  76085. name?: string | undefined;
  76086. private _isChecked;
  76087. private _background;
  76088. private _checkSizeRatio;
  76089. private _thickness;
  76090. /** Gets or sets border thickness */
  76091. get thickness(): number;
  76092. set thickness(value: number);
  76093. /** Gets or sets group name */
  76094. group: string;
  76095. /** BABYLON.Observable raised when isChecked is changed */
  76096. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76097. /** Gets or sets a value indicating the ratio between overall size and check size */
  76098. get checkSizeRatio(): number;
  76099. set checkSizeRatio(value: number);
  76100. /** Gets or sets background color */
  76101. get background(): string;
  76102. set background(value: string);
  76103. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76104. get isChecked(): boolean;
  76105. set isChecked(value: boolean);
  76106. /**
  76107. * Creates a new RadioButton
  76108. * @param name defines the control name
  76109. */
  76110. constructor(name?: string | undefined);
  76111. protected _getTypeName(): string;
  76112. _draw(context: CanvasRenderingContext2D): void;
  76113. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76114. /**
  76115. * Utility function to easily create a radio button with a header
  76116. * @param title defines the label to use for the header
  76117. * @param group defines the group to use for the radio button
  76118. * @param isChecked defines the initial state of the radio button
  76119. * @param onValueChanged defines the callback to call when value changes
  76120. * @returns a StackPanel containing the radio button and a textBlock
  76121. */
  76122. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76123. }
  76124. }
  76125. declare module BABYLON.GUI {
  76126. /**
  76127. * Class used to create slider controls
  76128. */
  76129. export class BaseSlider extends Control {
  76130. name?: string | undefined;
  76131. protected _thumbWidth: ValueAndUnit;
  76132. private _minimum;
  76133. private _maximum;
  76134. private _value;
  76135. private _isVertical;
  76136. protected _barOffset: ValueAndUnit;
  76137. private _isThumbClamped;
  76138. protected _displayThumb: boolean;
  76139. private _step;
  76140. private _lastPointerDownID;
  76141. protected _effectiveBarOffset: number;
  76142. protected _renderLeft: number;
  76143. protected _renderTop: number;
  76144. protected _renderWidth: number;
  76145. protected _renderHeight: number;
  76146. protected _backgroundBoxLength: number;
  76147. protected _backgroundBoxThickness: number;
  76148. protected _effectiveThumbThickness: number;
  76149. /** BABYLON.Observable raised when the sldier value changes */
  76150. onValueChangedObservable: BABYLON.Observable<number>;
  76151. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76152. get displayThumb(): boolean;
  76153. set displayThumb(value: boolean);
  76154. /** Gets or sets a step to apply to values (0 by default) */
  76155. get step(): number;
  76156. set step(value: number);
  76157. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76158. get barOffset(): string | number;
  76159. /** Gets main bar offset in pixels*/
  76160. get barOffsetInPixels(): number;
  76161. set barOffset(value: string | number);
  76162. /** Gets or sets thumb width */
  76163. get thumbWidth(): string | number;
  76164. /** Gets thumb width in pixels */
  76165. get thumbWidthInPixels(): number;
  76166. set thumbWidth(value: string | number);
  76167. /** Gets or sets minimum value */
  76168. get minimum(): number;
  76169. set minimum(value: number);
  76170. /** Gets or sets maximum value */
  76171. get maximum(): number;
  76172. set maximum(value: number);
  76173. /** Gets or sets current value */
  76174. get value(): number;
  76175. set value(value: number);
  76176. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76177. get isVertical(): boolean;
  76178. set isVertical(value: boolean);
  76179. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76180. get isThumbClamped(): boolean;
  76181. set isThumbClamped(value: boolean);
  76182. /**
  76183. * Creates a new BaseSlider
  76184. * @param name defines the control name
  76185. */
  76186. constructor(name?: string | undefined);
  76187. protected _getTypeName(): string;
  76188. protected _getThumbPosition(): number;
  76189. protected _getThumbThickness(type: string): number;
  76190. protected _prepareRenderingData(type: string): void;
  76191. private _pointerIsDown;
  76192. /** @hidden */
  76193. protected _updateValueFromPointer(x: number, y: number): void;
  76194. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76195. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76196. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76197. }
  76198. }
  76199. declare module BABYLON.GUI {
  76200. /**
  76201. * Class used to create slider controls
  76202. */
  76203. export class Slider extends BaseSlider {
  76204. name?: string | undefined;
  76205. private _background;
  76206. private _borderColor;
  76207. private _isThumbCircle;
  76208. protected _displayValueBar: boolean;
  76209. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76210. get displayValueBar(): boolean;
  76211. set displayValueBar(value: boolean);
  76212. /** Gets or sets border color */
  76213. get borderColor(): string;
  76214. set borderColor(value: string);
  76215. /** Gets or sets background color */
  76216. get background(): string;
  76217. set background(value: string);
  76218. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76219. get isThumbCircle(): boolean;
  76220. set isThumbCircle(value: boolean);
  76221. /**
  76222. * Creates a new Slider
  76223. * @param name defines the control name
  76224. */
  76225. constructor(name?: string | undefined);
  76226. protected _getTypeName(): string;
  76227. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76228. }
  76229. }
  76230. declare module BABYLON.GUI {
  76231. /** Class used to create a RadioGroup
  76232. * which contains groups of radio buttons
  76233. */
  76234. export class SelectorGroup {
  76235. /** name of SelectorGroup */
  76236. name: string;
  76237. private _groupPanel;
  76238. private _selectors;
  76239. private _groupHeader;
  76240. /**
  76241. * Creates a new SelectorGroup
  76242. * @param name of group, used as a group heading
  76243. */
  76244. constructor(
  76245. /** name of SelectorGroup */
  76246. name: string);
  76247. /** Gets the groupPanel of the SelectorGroup */
  76248. get groupPanel(): StackPanel;
  76249. /** Gets the selectors array */
  76250. get selectors(): StackPanel[];
  76251. /** Gets and sets the group header */
  76252. get header(): string;
  76253. set header(label: string);
  76254. /** @hidden */
  76255. private _addGroupHeader;
  76256. /** @hidden*/
  76257. _getSelector(selectorNb: number): StackPanel | undefined;
  76258. /** Removes the selector at the given position
  76259. * @param selectorNb the position of the selector within the group
  76260. */
  76261. removeSelector(selectorNb: number): void;
  76262. }
  76263. /** Class used to create a CheckboxGroup
  76264. * which contains groups of checkbox buttons
  76265. */
  76266. export class CheckboxGroup extends SelectorGroup {
  76267. /** Adds a checkbox as a control
  76268. * @param text is the label for the selector
  76269. * @param func is the function called when the Selector is checked
  76270. * @param checked is true when Selector is checked
  76271. */
  76272. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76273. /** @hidden */
  76274. _setSelectorLabel(selectorNb: number, label: string): void;
  76275. /** @hidden */
  76276. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76277. /** @hidden */
  76278. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76279. /** @hidden */
  76280. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76281. }
  76282. /** Class used to create a RadioGroup
  76283. * which contains groups of radio buttons
  76284. */
  76285. export class RadioGroup extends SelectorGroup {
  76286. private _selectNb;
  76287. /** Adds a radio button as a control
  76288. * @param label is the label for the selector
  76289. * @param func is the function called when the Selector is checked
  76290. * @param checked is true when Selector is checked
  76291. */
  76292. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76293. /** @hidden */
  76294. _setSelectorLabel(selectorNb: number, label: string): void;
  76295. /** @hidden */
  76296. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76297. /** @hidden */
  76298. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76299. /** @hidden */
  76300. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76301. }
  76302. /** Class used to create a SliderGroup
  76303. * which contains groups of slider buttons
  76304. */
  76305. export class SliderGroup extends SelectorGroup {
  76306. /**
  76307. * Adds a slider to the SelectorGroup
  76308. * @param label is the label for the SliderBar
  76309. * @param func is the function called when the Slider moves
  76310. * @param unit is a string describing the units used, eg degrees or metres
  76311. * @param min is the minimum value for the Slider
  76312. * @param max is the maximum value for the Slider
  76313. * @param value is the start value for the Slider between min and max
  76314. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76315. */
  76316. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76317. /** @hidden */
  76318. _setSelectorLabel(selectorNb: number, label: string): void;
  76319. /** @hidden */
  76320. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76321. /** @hidden */
  76322. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76323. /** @hidden */
  76324. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76325. }
  76326. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76327. * @see http://doc.babylonjs.com/how_to/selector
  76328. */
  76329. export class SelectionPanel extends Rectangle {
  76330. /** name of SelectionPanel */
  76331. name: string;
  76332. /** an array of SelectionGroups */
  76333. groups: SelectorGroup[];
  76334. private _panel;
  76335. private _buttonColor;
  76336. private _buttonBackground;
  76337. private _headerColor;
  76338. private _barColor;
  76339. private _barHeight;
  76340. private _spacerHeight;
  76341. private _labelColor;
  76342. private _groups;
  76343. private _bars;
  76344. /**
  76345. * Creates a new SelectionPanel
  76346. * @param name of SelectionPanel
  76347. * @param groups is an array of SelectionGroups
  76348. */
  76349. constructor(
  76350. /** name of SelectionPanel */
  76351. name: string,
  76352. /** an array of SelectionGroups */
  76353. groups?: SelectorGroup[]);
  76354. protected _getTypeName(): string;
  76355. /** Gets or sets the headerColor */
  76356. get headerColor(): string;
  76357. set headerColor(color: string);
  76358. private _setHeaderColor;
  76359. /** Gets or sets the button color */
  76360. get buttonColor(): string;
  76361. set buttonColor(color: string);
  76362. private _setbuttonColor;
  76363. /** Gets or sets the label color */
  76364. get labelColor(): string;
  76365. set labelColor(color: string);
  76366. private _setLabelColor;
  76367. /** Gets or sets the button background */
  76368. get buttonBackground(): string;
  76369. set buttonBackground(color: string);
  76370. private _setButtonBackground;
  76371. /** Gets or sets the color of separator bar */
  76372. get barColor(): string;
  76373. set barColor(color: string);
  76374. private _setBarColor;
  76375. /** Gets or sets the height of separator bar */
  76376. get barHeight(): string;
  76377. set barHeight(value: string);
  76378. private _setBarHeight;
  76379. /** Gets or sets the height of spacers*/
  76380. get spacerHeight(): string;
  76381. set spacerHeight(value: string);
  76382. private _setSpacerHeight;
  76383. /** Adds a bar between groups */
  76384. private _addSpacer;
  76385. /** Add a group to the selection panel
  76386. * @param group is the selector group to add
  76387. */
  76388. addGroup(group: SelectorGroup): void;
  76389. /** Remove the group from the given position
  76390. * @param groupNb is the position of the group in the list
  76391. */
  76392. removeGroup(groupNb: number): void;
  76393. /** Change a group header label
  76394. * @param label is the new group header label
  76395. * @param groupNb is the number of the group to relabel
  76396. * */
  76397. setHeaderName(label: string, groupNb: number): void;
  76398. /** Change selector label to the one given
  76399. * @param label is the new selector label
  76400. * @param groupNb is the number of the groupcontaining the selector
  76401. * @param selectorNb is the number of the selector within a group to relabel
  76402. * */
  76403. relabel(label: string, groupNb: number, selectorNb: number): void;
  76404. /** For a given group position remove the selector at the given position
  76405. * @param groupNb is the number of the group to remove the selector from
  76406. * @param selectorNb is the number of the selector within the group
  76407. */
  76408. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  76409. /** For a given group position of correct type add a checkbox button
  76410. * @param groupNb is the number of the group to remove the selector from
  76411. * @param label is the label for the selector
  76412. * @param func is the function called when the Selector is checked
  76413. * @param checked is true when Selector is checked
  76414. */
  76415. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76416. /** For a given group position of correct type add a radio button
  76417. * @param groupNb is the number of the group to remove the selector from
  76418. * @param label is the label for the selector
  76419. * @param func is the function called when the Selector is checked
  76420. * @param checked is true when Selector is checked
  76421. */
  76422. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76423. /**
  76424. * For a given slider group add a slider
  76425. * @param groupNb is the number of the group to add the slider to
  76426. * @param label is the label for the Slider
  76427. * @param func is the function called when the Slider moves
  76428. * @param unit is a string describing the units used, eg degrees or metres
  76429. * @param min is the minimum value for the Slider
  76430. * @param max is the maximum value for the Slider
  76431. * @param value is the start value for the Slider between min and max
  76432. * @param onVal is the function used to format the value displayed, eg radians to degrees
  76433. */
  76434. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  76435. }
  76436. }
  76437. declare module BABYLON.GUI {
  76438. /**
  76439. * Class used to hold a the container for ScrollViewer
  76440. * @hidden
  76441. */
  76442. export class _ScrollViewerWindow extends Container {
  76443. parentClientWidth: number;
  76444. parentClientHeight: number;
  76445. private _freezeControls;
  76446. private _parentMeasure;
  76447. private _oldLeft;
  76448. private _oldTop;
  76449. get freezeControls(): boolean;
  76450. set freezeControls(value: boolean);
  76451. private _bucketWidth;
  76452. private _bucketHeight;
  76453. private _buckets;
  76454. private _bucketLen;
  76455. get bucketWidth(): number;
  76456. get bucketHeight(): number;
  76457. setBucketSizes(width: number, height: number): void;
  76458. private _useBuckets;
  76459. private _makeBuckets;
  76460. private _dispatchInBuckets;
  76461. private _updateMeasures;
  76462. private _updateChildrenMeasures;
  76463. private _restoreMeasures;
  76464. /**
  76465. * Creates a new ScrollViewerWindow
  76466. * @param name of ScrollViewerWindow
  76467. */
  76468. constructor(name?: string);
  76469. protected _getTypeName(): string;
  76470. /** @hidden */
  76471. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76472. /** @hidden */
  76473. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76474. private _scrollChildren;
  76475. private _scrollChildrenWithBuckets;
  76476. /** @hidden */
  76477. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76478. protected _postMeasure(): void;
  76479. }
  76480. }
  76481. declare module BABYLON.GUI {
  76482. /**
  76483. * Class used to create slider controls
  76484. */
  76485. export class ScrollBar extends BaseSlider {
  76486. name?: string | undefined;
  76487. private _background;
  76488. private _borderColor;
  76489. private _tempMeasure;
  76490. /** Gets or sets border color */
  76491. get borderColor(): string;
  76492. set borderColor(value: string);
  76493. /** Gets or sets background color */
  76494. get background(): string;
  76495. set background(value: string);
  76496. /**
  76497. * Creates a new Slider
  76498. * @param name defines the control name
  76499. */
  76500. constructor(name?: string | undefined);
  76501. protected _getTypeName(): string;
  76502. protected _getThumbThickness(): number;
  76503. _draw(context: CanvasRenderingContext2D): void;
  76504. private _first;
  76505. private _originX;
  76506. private _originY;
  76507. /** @hidden */
  76508. protected _updateValueFromPointer(x: number, y: number): void;
  76509. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76510. }
  76511. }
  76512. declare module BABYLON.GUI {
  76513. /**
  76514. * Class used to create slider controls
  76515. */
  76516. export class ImageScrollBar extends BaseSlider {
  76517. name?: string | undefined;
  76518. private _backgroundBaseImage;
  76519. private _backgroundImage;
  76520. private _thumbImage;
  76521. private _thumbBaseImage;
  76522. private _thumbLength;
  76523. private _thumbHeight;
  76524. private _barImageHeight;
  76525. private _tempMeasure;
  76526. /** Number of 90° rotation to apply on the images when in vertical mode */
  76527. num90RotationInVerticalMode: number;
  76528. /**
  76529. * Gets or sets the image used to render the background for horizontal bar
  76530. */
  76531. get backgroundImage(): Image;
  76532. set backgroundImage(value: Image);
  76533. /**
  76534. * Gets or sets the image used to render the thumb
  76535. */
  76536. get thumbImage(): Image;
  76537. set thumbImage(value: Image);
  76538. /**
  76539. * Gets or sets the length of the thumb
  76540. */
  76541. get thumbLength(): number;
  76542. set thumbLength(value: number);
  76543. /**
  76544. * Gets or sets the height of the thumb
  76545. */
  76546. get thumbHeight(): number;
  76547. set thumbHeight(value: number);
  76548. /**
  76549. * Gets or sets the height of the bar image
  76550. */
  76551. get barImageHeight(): number;
  76552. set barImageHeight(value: number);
  76553. /**
  76554. * Creates a new ImageScrollBar
  76555. * @param name defines the control name
  76556. */
  76557. constructor(name?: string | undefined);
  76558. protected _getTypeName(): string;
  76559. protected _getThumbThickness(): number;
  76560. _draw(context: CanvasRenderingContext2D): void;
  76561. private _first;
  76562. private _originX;
  76563. private _originY;
  76564. /** @hidden */
  76565. protected _updateValueFromPointer(x: number, y: number): void;
  76566. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76567. }
  76568. }
  76569. declare module BABYLON.GUI {
  76570. /**
  76571. * Class used to hold a viewer window and sliders in a grid
  76572. */
  76573. export class ScrollViewer extends Rectangle {
  76574. private _grid;
  76575. private _horizontalBarSpace;
  76576. private _verticalBarSpace;
  76577. private _dragSpace;
  76578. private _horizontalBar;
  76579. private _verticalBar;
  76580. private _barColor;
  76581. private _barBackground;
  76582. private _barImage;
  76583. private _horizontalBarImage;
  76584. private _verticalBarImage;
  76585. private _barBackgroundImage;
  76586. private _horizontalBarBackgroundImage;
  76587. private _verticalBarBackgroundImage;
  76588. private _barSize;
  76589. private _window;
  76590. private _pointerIsOver;
  76591. private _wheelPrecision;
  76592. private _onWheelObserver;
  76593. private _clientWidth;
  76594. private _clientHeight;
  76595. private _useImageBar;
  76596. private _thumbLength;
  76597. private _thumbHeight;
  76598. private _barImageHeight;
  76599. private _horizontalBarImageHeight;
  76600. private _verticalBarImageHeight;
  76601. private _oldWindowContentsWidth;
  76602. private _oldWindowContentsHeight;
  76603. /**
  76604. * Gets the horizontal scrollbar
  76605. */
  76606. get horizontalBar(): ScrollBar | ImageScrollBar;
  76607. /**
  76608. * Gets the vertical scrollbar
  76609. */
  76610. get verticalBar(): ScrollBar | ImageScrollBar;
  76611. /**
  76612. * Adds a new control to the current container
  76613. * @param control defines the control to add
  76614. * @returns the current container
  76615. */
  76616. addControl(control: BABYLON.Nullable<Control>): Container;
  76617. /**
  76618. * Removes a control from the current container
  76619. * @param control defines the control to remove
  76620. * @returns the current container
  76621. */
  76622. removeControl(control: Control): Container;
  76623. /** Gets the list of children */
  76624. get children(): Control[];
  76625. _flagDescendantsAsMatrixDirty(): void;
  76626. /**
  76627. * Freezes or unfreezes the controls in the window.
  76628. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  76629. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  76630. */
  76631. get freezeControls(): boolean;
  76632. set freezeControls(value: boolean);
  76633. /** Gets the bucket width */
  76634. get bucketWidth(): number;
  76635. /** Gets the bucket height */
  76636. get bucketHeight(): number;
  76637. /**
  76638. * Sets the bucket sizes.
  76639. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  76640. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  76641. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  76642. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  76643. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  76644. * used), that's why it is not enabled by default.
  76645. * @param width width of the bucket
  76646. * @param height height of the bucket
  76647. */
  76648. setBucketSizes(width: number, height: number): void;
  76649. private _forceHorizontalBar;
  76650. private _forceVerticalBar;
  76651. /**
  76652. * Forces the horizontal scroll bar to be displayed
  76653. */
  76654. get forceHorizontalBar(): boolean;
  76655. set forceHorizontalBar(value: boolean);
  76656. /**
  76657. * Forces the vertical scroll bar to be displayed
  76658. */
  76659. get forceVerticalBar(): boolean;
  76660. set forceVerticalBar(value: boolean);
  76661. /**
  76662. * Creates a new ScrollViewer
  76663. * @param name of ScrollViewer
  76664. */
  76665. constructor(name?: string, isImageBased?: boolean);
  76666. /** Reset the scroll viewer window to initial size */
  76667. resetWindow(): void;
  76668. protected _getTypeName(): string;
  76669. private _buildClientSizes;
  76670. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76671. protected _postMeasure(): void;
  76672. /**
  76673. * Gets or sets the mouse wheel precision
  76674. * from 0 to 1 with a default value of 0.05
  76675. * */
  76676. get wheelPrecision(): number;
  76677. set wheelPrecision(value: number);
  76678. /** Gets or sets the scroll bar container background color */
  76679. get scrollBackground(): string;
  76680. set scrollBackground(color: string);
  76681. /** Gets or sets the bar color */
  76682. get barColor(): string;
  76683. set barColor(color: string);
  76684. /** Gets or sets the bar image */
  76685. get thumbImage(): Image;
  76686. set thumbImage(value: Image);
  76687. /** Gets or sets the horizontal bar image */
  76688. get horizontalThumbImage(): Image;
  76689. set horizontalThumbImage(value: Image);
  76690. /** Gets or sets the vertical bar image */
  76691. get verticalThumbImage(): Image;
  76692. set verticalThumbImage(value: Image);
  76693. /** Gets or sets the size of the bar */
  76694. get barSize(): number;
  76695. set barSize(value: number);
  76696. /** Gets or sets the length of the thumb */
  76697. get thumbLength(): number;
  76698. set thumbLength(value: number);
  76699. /** Gets or sets the height of the thumb */
  76700. get thumbHeight(): number;
  76701. set thumbHeight(value: number);
  76702. /** Gets or sets the height of the bar image */
  76703. get barImageHeight(): number;
  76704. set barImageHeight(value: number);
  76705. /** Gets or sets the height of the horizontal bar image */
  76706. get horizontalBarImageHeight(): number;
  76707. set horizontalBarImageHeight(value: number);
  76708. /** Gets or sets the height of the vertical bar image */
  76709. get verticalBarImageHeight(): number;
  76710. set verticalBarImageHeight(value: number);
  76711. /** Gets or sets the bar background */
  76712. get barBackground(): string;
  76713. set barBackground(color: string);
  76714. /** Gets or sets the bar background image */
  76715. get barImage(): Image;
  76716. set barImage(value: Image);
  76717. /** Gets or sets the horizontal bar background image */
  76718. get horizontalBarImage(): Image;
  76719. set horizontalBarImage(value: Image);
  76720. /** Gets or sets the vertical bar background image */
  76721. get verticalBarImage(): Image;
  76722. set verticalBarImage(value: Image);
  76723. private _setWindowPosition;
  76724. /** @hidden */
  76725. private _updateScroller;
  76726. _link(host: AdvancedDynamicTexture): void;
  76727. /** @hidden */
  76728. private _addBar;
  76729. /** @hidden */
  76730. private _attachWheel;
  76731. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76732. /** Releases associated resources */
  76733. dispose(): void;
  76734. }
  76735. }
  76736. declare module BABYLON.GUI {
  76737. /** Class used to render a grid */
  76738. export class DisplayGrid extends Control {
  76739. name?: string | undefined;
  76740. private _cellWidth;
  76741. private _cellHeight;
  76742. private _minorLineTickness;
  76743. private _minorLineColor;
  76744. private _majorLineTickness;
  76745. private _majorLineColor;
  76746. private _majorLineFrequency;
  76747. private _background;
  76748. private _displayMajorLines;
  76749. private _displayMinorLines;
  76750. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  76751. get displayMinorLines(): boolean;
  76752. set displayMinorLines(value: boolean);
  76753. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  76754. get displayMajorLines(): boolean;
  76755. set displayMajorLines(value: boolean);
  76756. /** Gets or sets background color (Black by default) */
  76757. get background(): string;
  76758. set background(value: string);
  76759. /** Gets or sets the width of each cell (20 by default) */
  76760. get cellWidth(): number;
  76761. set cellWidth(value: number);
  76762. /** Gets or sets the height of each cell (20 by default) */
  76763. get cellHeight(): number;
  76764. set cellHeight(value: number);
  76765. /** Gets or sets the tickness of minor lines (1 by default) */
  76766. get minorLineTickness(): number;
  76767. set minorLineTickness(value: number);
  76768. /** Gets or sets the color of minor lines (DarkGray by default) */
  76769. get minorLineColor(): string;
  76770. set minorLineColor(value: string);
  76771. /** Gets or sets the tickness of major lines (2 by default) */
  76772. get majorLineTickness(): number;
  76773. set majorLineTickness(value: number);
  76774. /** Gets or sets the color of major lines (White by default) */
  76775. get majorLineColor(): string;
  76776. set majorLineColor(value: string);
  76777. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  76778. get majorLineFrequency(): number;
  76779. set majorLineFrequency(value: number);
  76780. /**
  76781. * Creates a new GridDisplayRectangle
  76782. * @param name defines the control name
  76783. */
  76784. constructor(name?: string | undefined);
  76785. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76786. protected _getTypeName(): string;
  76787. }
  76788. }
  76789. declare module BABYLON.GUI {
  76790. /**
  76791. * Class used to create slider controls based on images
  76792. */
  76793. export class ImageBasedSlider extends BaseSlider {
  76794. name?: string | undefined;
  76795. private _backgroundImage;
  76796. private _thumbImage;
  76797. private _valueBarImage;
  76798. private _tempMeasure;
  76799. get displayThumb(): boolean;
  76800. set displayThumb(value: boolean);
  76801. /**
  76802. * Gets or sets the image used to render the background
  76803. */
  76804. get backgroundImage(): Image;
  76805. set backgroundImage(value: Image);
  76806. /**
  76807. * Gets or sets the image used to render the value bar
  76808. */
  76809. get valueBarImage(): Image;
  76810. set valueBarImage(value: Image);
  76811. /**
  76812. * Gets or sets the image used to render the thumb
  76813. */
  76814. get thumbImage(): Image;
  76815. set thumbImage(value: Image);
  76816. /**
  76817. * Creates a new ImageBasedSlider
  76818. * @param name defines the control name
  76819. */
  76820. constructor(name?: string | undefined);
  76821. protected _getTypeName(): string;
  76822. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76823. }
  76824. }
  76825. declare module BABYLON.GUI {
  76826. /**
  76827. * Forcing an export so that this code will execute
  76828. * @hidden
  76829. */
  76830. const name = "Statics";
  76831. }
  76832. declare module BABYLON.GUI {
  76833. /**
  76834. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  76835. */
  76836. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  76837. /**
  76838. * Define the instrumented AdvancedDynamicTexture.
  76839. */
  76840. texture: AdvancedDynamicTexture;
  76841. private _captureRenderTime;
  76842. private _renderTime;
  76843. private _captureLayoutTime;
  76844. private _layoutTime;
  76845. private _onBeginRenderObserver;
  76846. private _onEndRenderObserver;
  76847. private _onBeginLayoutObserver;
  76848. private _onEndLayoutObserver;
  76849. /**
  76850. * Gets the perf counter used to capture render time
  76851. */
  76852. get renderTimeCounter(): BABYLON.PerfCounter;
  76853. /**
  76854. * Gets the perf counter used to capture layout time
  76855. */
  76856. get layoutTimeCounter(): BABYLON.PerfCounter;
  76857. /**
  76858. * Enable or disable the render time capture
  76859. */
  76860. get captureRenderTime(): boolean;
  76861. set captureRenderTime(value: boolean);
  76862. /**
  76863. * Enable or disable the layout time capture
  76864. */
  76865. get captureLayoutTime(): boolean;
  76866. set captureLayoutTime(value: boolean);
  76867. /**
  76868. * Instantiates a new advanced dynamic texture instrumentation.
  76869. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  76870. * @param texture Defines the AdvancedDynamicTexture to instrument
  76871. */
  76872. constructor(
  76873. /**
  76874. * Define the instrumented AdvancedDynamicTexture.
  76875. */
  76876. texture: AdvancedDynamicTexture);
  76877. /**
  76878. * Dispose and release associated resources.
  76879. */
  76880. dispose(): void;
  76881. }
  76882. }
  76883. declare module BABYLON.GUI {
  76884. /**
  76885. * Class used to load GUI via XML.
  76886. */
  76887. export class XmlLoader {
  76888. private _nodes;
  76889. private _nodeTypes;
  76890. private _isLoaded;
  76891. private _objectAttributes;
  76892. private _parentClass;
  76893. /**
  76894. * Create a new xml loader
  76895. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  76896. */
  76897. constructor(parentClass?: null);
  76898. private _getChainElement;
  76899. private _getClassAttribute;
  76900. private _createGuiElement;
  76901. private _parseGrid;
  76902. private _parseElement;
  76903. private _prepareSourceElement;
  76904. private _parseElementsFromSource;
  76905. private _parseXml;
  76906. /**
  76907. * Gets if the loading has finished.
  76908. * @returns whether the loading has finished or not
  76909. */
  76910. isLoaded(): boolean;
  76911. /**
  76912. * Gets a loaded node / control by id.
  76913. * @param id the Controls id set in the xml
  76914. * @returns element of type Control
  76915. */
  76916. getNodeById(id: string): any;
  76917. /**
  76918. * Gets all loaded nodes / controls
  76919. * @returns Array of controls
  76920. */
  76921. getNodes(): any;
  76922. /**
  76923. * Initiates the xml layout loading
  76924. * @param xmlFile defines the xml layout to load
  76925. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  76926. * @param callback defines the callback called on layout load.
  76927. */
  76928. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  76929. }
  76930. }
  76931. declare module BABYLON.GUI {
  76932. /**
  76933. * Class used to create containers for controls
  76934. */
  76935. export class Container3D extends Control3D {
  76936. private _blockLayout;
  76937. /**
  76938. * Gets the list of child controls
  76939. */
  76940. protected _children: Control3D[];
  76941. /**
  76942. * Gets the list of child controls
  76943. */
  76944. get children(): Array<Control3D>;
  76945. /**
  76946. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  76947. * This is helpful to optimize layout operation when adding multiple children in a row
  76948. */
  76949. get blockLayout(): boolean;
  76950. set blockLayout(value: boolean);
  76951. /**
  76952. * Creates a new container
  76953. * @param name defines the container name
  76954. */
  76955. constructor(name?: string);
  76956. /**
  76957. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  76958. * @returns the current container
  76959. */
  76960. updateLayout(): Container3D;
  76961. /**
  76962. * Gets a boolean indicating if the given control is in the children of this control
  76963. * @param control defines the control to check
  76964. * @returns true if the control is in the child list
  76965. */
  76966. containsControl(control: Control3D): boolean;
  76967. /**
  76968. * Adds a control to the children of this control
  76969. * @param control defines the control to add
  76970. * @returns the current container
  76971. */
  76972. addControl(control: Control3D): Container3D;
  76973. /**
  76974. * This function will be called everytime a new control is added
  76975. */
  76976. protected _arrangeChildren(): void;
  76977. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  76978. /**
  76979. * Removes a control from the children of this control
  76980. * @param control defines the control to remove
  76981. * @returns the current container
  76982. */
  76983. removeControl(control: Control3D): Container3D;
  76984. protected _getTypeName(): string;
  76985. /**
  76986. * Releases all associated resources
  76987. */
  76988. dispose(): void;
  76989. /** Control rotation will remain unchanged */
  76990. static readonly UNSET_ORIENTATION: number;
  76991. /** Control will rotate to make it look at sphere central axis */
  76992. static readonly FACEORIGIN_ORIENTATION: number;
  76993. /** Control will rotate to make it look back at sphere central axis */
  76994. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  76995. /** Control will rotate to look at z axis (0, 0, 1) */
  76996. static readonly FACEFORWARD_ORIENTATION: number;
  76997. /** Control will rotate to look at negative z axis (0, 0, -1) */
  76998. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  76999. }
  77000. }
  77001. declare module BABYLON.GUI {
  77002. /**
  77003. * Class used to manage 3D user interface
  77004. * @see http://doc.babylonjs.com/how_to/gui3d
  77005. */
  77006. export class GUI3DManager implements BABYLON.IDisposable {
  77007. private _scene;
  77008. private _sceneDisposeObserver;
  77009. private _utilityLayer;
  77010. private _rootContainer;
  77011. private _pointerObserver;
  77012. private _pointerOutObserver;
  77013. /** @hidden */
  77014. _lastPickedControl: Control3D;
  77015. /** @hidden */
  77016. _lastControlOver: {
  77017. [pointerId: number]: Control3D;
  77018. };
  77019. /** @hidden */
  77020. _lastControlDown: {
  77021. [pointerId: number]: Control3D;
  77022. };
  77023. /**
  77024. * BABYLON.Observable raised when the point picked by the pointer events changed
  77025. */
  77026. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  77027. /** @hidden */
  77028. _sharedMaterials: {
  77029. [key: string]: BABYLON.Material;
  77030. };
  77031. /** Gets the hosting scene */
  77032. get scene(): BABYLON.Scene;
  77033. /** Gets associated utility layer */
  77034. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77035. /**
  77036. * Creates a new GUI3DManager
  77037. * @param scene
  77038. */
  77039. constructor(scene?: BABYLON.Scene);
  77040. private _handlePointerOut;
  77041. private _doPicking;
  77042. /**
  77043. * Gets the root container
  77044. */
  77045. get rootContainer(): Container3D;
  77046. /**
  77047. * Gets a boolean indicating if the given control is in the root child list
  77048. * @param control defines the control to check
  77049. * @returns true if the control is in the root child list
  77050. */
  77051. containsControl(control: Control3D): boolean;
  77052. /**
  77053. * Adds a control to the root child list
  77054. * @param control defines the control to add
  77055. * @returns the current manager
  77056. */
  77057. addControl(control: Control3D): GUI3DManager;
  77058. /**
  77059. * Removes a control from the root child list
  77060. * @param control defines the control to remove
  77061. * @returns the current container
  77062. */
  77063. removeControl(control: Control3D): GUI3DManager;
  77064. /**
  77065. * Releases all associated resources
  77066. */
  77067. dispose(): void;
  77068. }
  77069. }
  77070. declare module BABYLON.GUI {
  77071. /**
  77072. * Class used to transport BABYLON.Vector3 information for pointer events
  77073. */
  77074. export class Vector3WithInfo extends BABYLON.Vector3 {
  77075. /** defines the current mouse button index */
  77076. buttonIndex: number;
  77077. /**
  77078. * Creates a new Vector3WithInfo
  77079. * @param source defines the vector3 data to transport
  77080. * @param buttonIndex defines the current mouse button index
  77081. */
  77082. constructor(source: BABYLON.Vector3,
  77083. /** defines the current mouse button index */
  77084. buttonIndex?: number);
  77085. }
  77086. }
  77087. declare module BABYLON.GUI {
  77088. /**
  77089. * Class used as base class for controls
  77090. */
  77091. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77092. /** Defines the control name */
  77093. name?: string | undefined;
  77094. /** @hidden */
  77095. _host: GUI3DManager;
  77096. private _node;
  77097. private _downCount;
  77098. private _enterCount;
  77099. private _downPointerIds;
  77100. private _isVisible;
  77101. /** Gets or sets the control position in world space */
  77102. get position(): BABYLON.Vector3;
  77103. set position(value: BABYLON.Vector3);
  77104. /** Gets or sets the control scaling in world space */
  77105. get scaling(): BABYLON.Vector3;
  77106. set scaling(value: BABYLON.Vector3);
  77107. /** Callback used to start pointer enter animation */
  77108. pointerEnterAnimation: () => void;
  77109. /** Callback used to start pointer out animation */
  77110. pointerOutAnimation: () => void;
  77111. /** Callback used to start pointer down animation */
  77112. pointerDownAnimation: () => void;
  77113. /** Callback used to start pointer up animation */
  77114. pointerUpAnimation: () => void;
  77115. /**
  77116. * An event triggered when the pointer move over the control
  77117. */
  77118. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77119. /**
  77120. * An event triggered when the pointer move out of the control
  77121. */
  77122. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77123. /**
  77124. * An event triggered when the pointer taps the control
  77125. */
  77126. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77127. /**
  77128. * An event triggered when pointer is up
  77129. */
  77130. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77131. /**
  77132. * An event triggered when a control is clicked on (with a mouse)
  77133. */
  77134. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77135. /**
  77136. * An event triggered when pointer enters the control
  77137. */
  77138. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77139. /**
  77140. * Gets or sets the parent container
  77141. */
  77142. parent: BABYLON.Nullable<Container3D>;
  77143. private _behaviors;
  77144. /**
  77145. * Gets the list of attached behaviors
  77146. * @see http://doc.babylonjs.com/features/behaviour
  77147. */
  77148. get behaviors(): BABYLON.Behavior<Control3D>[];
  77149. /**
  77150. * Attach a behavior to the control
  77151. * @see http://doc.babylonjs.com/features/behaviour
  77152. * @param behavior defines the behavior to attach
  77153. * @returns the current control
  77154. */
  77155. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77156. /**
  77157. * Remove an attached behavior
  77158. * @see http://doc.babylonjs.com/features/behaviour
  77159. * @param behavior defines the behavior to attach
  77160. * @returns the current control
  77161. */
  77162. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77163. /**
  77164. * Gets an attached behavior by name
  77165. * @param name defines the name of the behavior to look for
  77166. * @see http://doc.babylonjs.com/features/behaviour
  77167. * @returns null if behavior was not found else the requested behavior
  77168. */
  77169. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77170. /** Gets or sets a boolean indicating if the control is visible */
  77171. get isVisible(): boolean;
  77172. set isVisible(value: boolean);
  77173. /**
  77174. * Creates a new control
  77175. * @param name defines the control name
  77176. */
  77177. constructor(
  77178. /** Defines the control name */
  77179. name?: string | undefined);
  77180. /**
  77181. * Gets a string representing the class name
  77182. */
  77183. get typeName(): string;
  77184. /**
  77185. * Get the current class name of the control.
  77186. * @returns current class name
  77187. */
  77188. getClassName(): string;
  77189. protected _getTypeName(): string;
  77190. /**
  77191. * Gets the transform node used by this control
  77192. */
  77193. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77194. /**
  77195. * Gets the mesh used to render this control
  77196. */
  77197. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77198. /**
  77199. * Link the control as child of the given node
  77200. * @param node defines the node to link to. Use null to unlink the control
  77201. * @returns the current control
  77202. */
  77203. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77204. /** @hidden **/
  77205. _prepareNode(scene: BABYLON.Scene): void;
  77206. /**
  77207. * Node creation.
  77208. * Can be overriden by children
  77209. * @param scene defines the scene where the node must be attached
  77210. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77211. */
  77212. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77213. /**
  77214. * Affect a material to the given mesh
  77215. * @param mesh defines the mesh which will represent the control
  77216. */
  77217. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77218. /** @hidden */
  77219. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77220. /** @hidden */
  77221. _onPointerEnter(target: Control3D): boolean;
  77222. /** @hidden */
  77223. _onPointerOut(target: Control3D): void;
  77224. /** @hidden */
  77225. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77226. /** @hidden */
  77227. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77228. /** @hidden */
  77229. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77230. /** @hidden */
  77231. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77232. /** @hidden */
  77233. _disposeNode(): void;
  77234. /**
  77235. * Releases all associated resources
  77236. */
  77237. dispose(): void;
  77238. }
  77239. }
  77240. declare module BABYLON.GUI {
  77241. /**
  77242. * Class used as a root to all buttons
  77243. */
  77244. export class AbstractButton3D extends Control3D {
  77245. /**
  77246. * Creates a new button
  77247. * @param name defines the control name
  77248. */
  77249. constructor(name?: string);
  77250. protected _getTypeName(): string;
  77251. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77252. }
  77253. }
  77254. declare module BABYLON.GUI {
  77255. /**
  77256. * Class used to create a button in 3D
  77257. */
  77258. export class Button3D extends AbstractButton3D {
  77259. /** @hidden */
  77260. protected _currentMaterial: BABYLON.Material;
  77261. private _facadeTexture;
  77262. private _content;
  77263. private _contentResolution;
  77264. private _contentScaleRatio;
  77265. /**
  77266. * Gets or sets the texture resolution used to render content (512 by default)
  77267. */
  77268. get contentResolution(): BABYLON.int;
  77269. set contentResolution(value: BABYLON.int);
  77270. /**
  77271. * Gets or sets the texture scale ratio used to render content (2 by default)
  77272. */
  77273. get contentScaleRatio(): number;
  77274. set contentScaleRatio(value: number);
  77275. protected _disposeFacadeTexture(): void;
  77276. protected _resetContent(): void;
  77277. /**
  77278. * Creates a new button
  77279. * @param name defines the control name
  77280. */
  77281. constructor(name?: string);
  77282. /**
  77283. * Gets or sets the GUI 2D content used to display the button's facade
  77284. */
  77285. get content(): Control;
  77286. set content(value: Control);
  77287. /**
  77288. * Apply the facade texture (created from the content property).
  77289. * This function can be overloaded by child classes
  77290. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77291. */
  77292. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77293. protected _getTypeName(): string;
  77294. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77295. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77296. /**
  77297. * Releases all associated resources
  77298. */
  77299. dispose(): void;
  77300. }
  77301. }
  77302. declare module BABYLON.GUI {
  77303. /**
  77304. * Abstract class used to create a container panel deployed on the surface of a volume
  77305. */
  77306. export abstract class VolumeBasedPanel extends Container3D {
  77307. private _columns;
  77308. private _rows;
  77309. private _rowThenColum;
  77310. private _orientation;
  77311. protected _cellWidth: number;
  77312. protected _cellHeight: number;
  77313. /**
  77314. * Gets or sets the distance between elements
  77315. */
  77316. margin: number;
  77317. /**
  77318. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77319. * | Value | Type | Description |
  77320. * | ----- | ----------------------------------- | ----------- |
  77321. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77322. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77323. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77324. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77325. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77326. */
  77327. get orientation(): number;
  77328. set orientation(value: number);
  77329. /**
  77330. * Gets or sets the number of columns requested (10 by default).
  77331. * The panel will automatically compute the number of rows based on number of child controls.
  77332. */
  77333. get columns(): BABYLON.int;
  77334. set columns(value: BABYLON.int);
  77335. /**
  77336. * Gets or sets a the number of rows requested.
  77337. * The panel will automatically compute the number of columns based on number of child controls.
  77338. */
  77339. get rows(): BABYLON.int;
  77340. set rows(value: BABYLON.int);
  77341. /**
  77342. * Creates new VolumeBasedPanel
  77343. */
  77344. constructor();
  77345. protected _arrangeChildren(): void;
  77346. /** Child classes must implement this function to provide correct control positioning */
  77347. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77348. /** Child classes can implement this function to provide additional processing */
  77349. protected _finalProcessing(): void;
  77350. }
  77351. }
  77352. declare module BABYLON.GUI {
  77353. /**
  77354. * Class used to create a container panel deployed on the surface of a cylinder
  77355. */
  77356. export class CylinderPanel extends VolumeBasedPanel {
  77357. private _radius;
  77358. /**
  77359. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  77360. */
  77361. get radius(): BABYLON.float;
  77362. set radius(value: BABYLON.float);
  77363. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77364. private _cylindricalMapping;
  77365. }
  77366. }
  77367. declare module BABYLON.GUI {
  77368. /** @hidden */
  77369. export var fluentVertexShader: {
  77370. name: string;
  77371. shader: string;
  77372. };
  77373. }
  77374. declare module BABYLON.GUI {
  77375. /** @hidden */
  77376. export var fluentPixelShader: {
  77377. name: string;
  77378. shader: string;
  77379. };
  77380. }
  77381. declare module BABYLON.GUI {
  77382. /** @hidden */
  77383. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  77384. INNERGLOW: boolean;
  77385. BORDER: boolean;
  77386. HOVERLIGHT: boolean;
  77387. TEXTURE: boolean;
  77388. constructor();
  77389. }
  77390. /**
  77391. * Class used to render controls with fluent desgin
  77392. */
  77393. export class FluentMaterial extends BABYLON.PushMaterial {
  77394. /**
  77395. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  77396. */
  77397. innerGlowColorIntensity: number;
  77398. /**
  77399. * Gets or sets the inner glow color (white by default)
  77400. */
  77401. innerGlowColor: BABYLON.Color3;
  77402. /**
  77403. * Gets or sets alpha value (default is 1.0)
  77404. */
  77405. alpha: number;
  77406. /**
  77407. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  77408. */
  77409. albedoColor: BABYLON.Color3;
  77410. /**
  77411. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  77412. */
  77413. renderBorders: boolean;
  77414. /**
  77415. * Gets or sets border width (default is 0.5)
  77416. */
  77417. borderWidth: number;
  77418. /**
  77419. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  77420. */
  77421. edgeSmoothingValue: number;
  77422. /**
  77423. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  77424. */
  77425. borderMinValue: number;
  77426. /**
  77427. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  77428. */
  77429. renderHoverLight: boolean;
  77430. /**
  77431. * Gets or sets the radius used to render the hover light (default is 1.0)
  77432. */
  77433. hoverRadius: number;
  77434. /**
  77435. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  77436. */
  77437. hoverColor: BABYLON.Color4;
  77438. /**
  77439. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  77440. */
  77441. hoverPosition: BABYLON.Vector3;
  77442. private _albedoTexture;
  77443. /** Gets or sets the texture to use for albedo color */
  77444. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77445. /**
  77446. * Creates a new Fluent material
  77447. * @param name defines the name of the material
  77448. * @param scene defines the hosting scene
  77449. */
  77450. constructor(name: string, scene: BABYLON.Scene);
  77451. needAlphaBlending(): boolean;
  77452. needAlphaTesting(): boolean;
  77453. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77454. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77455. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77456. getActiveTextures(): BABYLON.BaseTexture[];
  77457. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77458. dispose(forceDisposeEffect?: boolean): void;
  77459. clone(name: string): FluentMaterial;
  77460. serialize(): any;
  77461. getClassName(): string;
  77462. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  77463. }
  77464. }
  77465. declare module BABYLON.GUI {
  77466. /**
  77467. * Class used to create a holographic button in 3D
  77468. */
  77469. export class HolographicButton extends Button3D {
  77470. private _backPlate;
  77471. private _textPlate;
  77472. private _frontPlate;
  77473. private _text;
  77474. private _imageUrl;
  77475. private _shareMaterials;
  77476. private _frontMaterial;
  77477. private _backMaterial;
  77478. private _plateMaterial;
  77479. private _pickedPointObserver;
  77480. private _tooltipFade;
  77481. private _tooltipTextBlock;
  77482. private _tooltipTexture;
  77483. private _tooltipMesh;
  77484. private _tooltipHoverObserver;
  77485. private _tooltipOutObserver;
  77486. private _disposeTooltip;
  77487. /**
  77488. * Rendering ground id of all the mesh in the button
  77489. */
  77490. set renderingGroupId(id: number);
  77491. get renderingGroupId(): number;
  77492. /**
  77493. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  77494. */
  77495. set tooltipText(text: BABYLON.Nullable<string>);
  77496. get tooltipText(): BABYLON.Nullable<string>;
  77497. /**
  77498. * Gets or sets text for the button
  77499. */
  77500. get text(): string;
  77501. set text(value: string);
  77502. /**
  77503. * Gets or sets the image url for the button
  77504. */
  77505. get imageUrl(): string;
  77506. set imageUrl(value: string);
  77507. /**
  77508. * Gets the back material used by this button
  77509. */
  77510. get backMaterial(): FluentMaterial;
  77511. /**
  77512. * Gets the front material used by this button
  77513. */
  77514. get frontMaterial(): FluentMaterial;
  77515. /**
  77516. * Gets the plate material used by this button
  77517. */
  77518. get plateMaterial(): BABYLON.StandardMaterial;
  77519. /**
  77520. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  77521. */
  77522. get shareMaterials(): boolean;
  77523. /**
  77524. * Creates a new button
  77525. * @param name defines the control name
  77526. */
  77527. constructor(name?: string, shareMaterials?: boolean);
  77528. protected _getTypeName(): string;
  77529. private _rebuildContent;
  77530. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77531. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77532. private _createBackMaterial;
  77533. private _createFrontMaterial;
  77534. private _createPlateMaterial;
  77535. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  77536. /**
  77537. * Releases all associated resources
  77538. */
  77539. dispose(): void;
  77540. }
  77541. }
  77542. declare module BABYLON.GUI {
  77543. /**
  77544. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  77545. */
  77546. export class MeshButton3D extends Button3D {
  77547. /** @hidden */
  77548. protected _currentMesh: BABYLON.Mesh;
  77549. /**
  77550. * Creates a new 3D button based on a mesh
  77551. * @param mesh mesh to become a 3D button
  77552. * @param name defines the control name
  77553. */
  77554. constructor(mesh: BABYLON.Mesh, name?: string);
  77555. protected _getTypeName(): string;
  77556. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77557. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77558. }
  77559. }
  77560. declare module BABYLON.GUI {
  77561. /**
  77562. * Class used to create a container panel deployed on the surface of a plane
  77563. */
  77564. export class PlanePanel extends VolumeBasedPanel {
  77565. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77566. }
  77567. }
  77568. declare module BABYLON.GUI {
  77569. /**
  77570. * Class used to create a container panel where items get randomized planar mapping
  77571. */
  77572. export class ScatterPanel extends VolumeBasedPanel {
  77573. private _iteration;
  77574. /**
  77575. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  77576. */
  77577. get iteration(): BABYLON.float;
  77578. set iteration(value: BABYLON.float);
  77579. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77580. private _scatterMapping;
  77581. protected _finalProcessing(): void;
  77582. }
  77583. }
  77584. declare module BABYLON.GUI {
  77585. /**
  77586. * Class used to create a container panel deployed on the surface of a sphere
  77587. */
  77588. export class SpherePanel extends VolumeBasedPanel {
  77589. private _radius;
  77590. /**
  77591. * Gets or sets the radius of the sphere where to project controls (5 by default)
  77592. */
  77593. get radius(): BABYLON.float;
  77594. set radius(value: BABYLON.float);
  77595. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77596. private _sphericalMapping;
  77597. }
  77598. }
  77599. declare module BABYLON.GUI {
  77600. /**
  77601. * Class used to create a stack panel in 3D on XY plane
  77602. */
  77603. export class StackPanel3D extends Container3D {
  77604. private _isVertical;
  77605. /**
  77606. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  77607. */
  77608. get isVertical(): boolean;
  77609. set isVertical(value: boolean);
  77610. /**
  77611. * Gets or sets the distance between elements
  77612. */
  77613. margin: number;
  77614. /**
  77615. * Creates new StackPanel
  77616. * @param isVertical
  77617. */
  77618. constructor(isVertical?: boolean);
  77619. protected _arrangeChildren(): void;
  77620. }
  77621. }
  77622. declare module BABYLON {
  77623. /**
  77624. * Configuration for glTF validation
  77625. */
  77626. export interface IGLTFValidationConfiguration {
  77627. /**
  77628. * The url of the glTF validator.
  77629. */
  77630. url: string;
  77631. }
  77632. /**
  77633. * glTF validation
  77634. */
  77635. export class GLTFValidation {
  77636. /**
  77637. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  77638. */
  77639. static Configuration: IGLTFValidationConfiguration;
  77640. private static _LoadScriptPromise;
  77641. /**
  77642. * Validate a glTF asset using the glTF-Validator.
  77643. * @param data The JSON of a glTF or the array buffer of a binary glTF
  77644. * @param rootUrl The root url for the glTF
  77645. * @param fileName The file name for the glTF
  77646. * @param getExternalResource The callback to get external resources for the glTF validator
  77647. * @returns A promise that resolves with the glTF validation results once complete
  77648. */
  77649. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  77650. }
  77651. }
  77652. declare module BABYLON {
  77653. /**
  77654. * Mode that determines the coordinate system to use.
  77655. */
  77656. export enum GLTFLoaderCoordinateSystemMode {
  77657. /**
  77658. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  77659. */
  77660. AUTO = 0,
  77661. /**
  77662. * Sets the useRightHandedSystem flag on the scene.
  77663. */
  77664. FORCE_RIGHT_HANDED = 1
  77665. }
  77666. /**
  77667. * Mode that determines what animations will start.
  77668. */
  77669. export enum GLTFLoaderAnimationStartMode {
  77670. /**
  77671. * No animation will start.
  77672. */
  77673. NONE = 0,
  77674. /**
  77675. * The first animation will start.
  77676. */
  77677. FIRST = 1,
  77678. /**
  77679. * All animations will start.
  77680. */
  77681. ALL = 2
  77682. }
  77683. /**
  77684. * Interface that contains the data for the glTF asset.
  77685. */
  77686. export interface IGLTFLoaderData {
  77687. /**
  77688. * The object that represents the glTF JSON.
  77689. */
  77690. json: Object;
  77691. /**
  77692. * The BIN chunk of a binary glTF.
  77693. */
  77694. bin: Nullable<IDataBuffer>;
  77695. }
  77696. /**
  77697. * Interface for extending the loader.
  77698. */
  77699. export interface IGLTFLoaderExtension {
  77700. /**
  77701. * The name of this extension.
  77702. */
  77703. readonly name: string;
  77704. /**
  77705. * Defines whether this extension is enabled.
  77706. */
  77707. enabled: boolean;
  77708. /**
  77709. * Defines the order of this extension.
  77710. * The loader sorts the extensions using these values when loading.
  77711. */
  77712. order?: number;
  77713. }
  77714. /**
  77715. * Loader state.
  77716. */
  77717. export enum GLTFLoaderState {
  77718. /**
  77719. * The asset is loading.
  77720. */
  77721. LOADING = 0,
  77722. /**
  77723. * The asset is ready for rendering.
  77724. */
  77725. READY = 1,
  77726. /**
  77727. * The asset is completely loaded.
  77728. */
  77729. COMPLETE = 2
  77730. }
  77731. /** @hidden */
  77732. export interface IImportMeshAsyncOutput {
  77733. meshes: AbstractMesh[];
  77734. particleSystems: IParticleSystem[];
  77735. skeletons: Skeleton[];
  77736. animationGroups: AnimationGroup[];
  77737. lights: Light[];
  77738. transformNodes: TransformNode[];
  77739. }
  77740. /** @hidden */
  77741. export interface IGLTFLoader extends IDisposable {
  77742. readonly state: Nullable<GLTFLoaderState>;
  77743. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  77744. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  77745. }
  77746. /**
  77747. * File loader for loading glTF files into a scene.
  77748. */
  77749. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77750. /** @hidden */
  77751. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77752. /** @hidden */
  77753. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77754. /**
  77755. * Raised when the asset has been parsed
  77756. */
  77757. onParsedObservable: Observable<IGLTFLoaderData>;
  77758. private _onParsedObserver;
  77759. /**
  77760. * Raised when the asset has been parsed
  77761. */
  77762. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  77763. /**
  77764. * 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.
  77765. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  77766. * Defaults to true.
  77767. * @hidden
  77768. */
  77769. static IncrementalLoading: boolean;
  77770. /**
  77771. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  77772. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  77773. * @hidden
  77774. */
  77775. static HomogeneousCoordinates: boolean;
  77776. /**
  77777. * The coordinate system mode. Defaults to AUTO.
  77778. */
  77779. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  77780. /**
  77781. * The animation start mode. Defaults to FIRST.
  77782. */
  77783. animationStartMode: GLTFLoaderAnimationStartMode;
  77784. /**
  77785. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  77786. */
  77787. compileMaterials: boolean;
  77788. /**
  77789. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  77790. */
  77791. useClipPlane: boolean;
  77792. /**
  77793. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  77794. */
  77795. compileShadowGenerators: boolean;
  77796. /**
  77797. * Defines if the Alpha blended materials are only applied as coverage.
  77798. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  77799. * If true, no extra effects are applied to transparent pixels.
  77800. */
  77801. transparencyAsCoverage: boolean;
  77802. /**
  77803. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  77804. * Enabling will disable offline support and glTF validator.
  77805. * Defaults to false.
  77806. */
  77807. useRangeRequests: boolean;
  77808. /**
  77809. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  77810. */
  77811. createInstances: boolean;
  77812. /**
  77813. * Function called before loading a url referenced by the asset.
  77814. */
  77815. preprocessUrlAsync: (url: string) => Promise<string>;
  77816. /**
  77817. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77818. */
  77819. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  77820. private _onMeshLoadedObserver;
  77821. /**
  77822. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77823. */
  77824. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  77825. /**
  77826. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  77827. */
  77828. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  77829. private _onTextureLoadedObserver;
  77830. /**
  77831. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  77832. */
  77833. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  77834. /**
  77835. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  77836. */
  77837. readonly onMaterialLoadedObservable: Observable<Material>;
  77838. private _onMaterialLoadedObserver;
  77839. /**
  77840. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  77841. */
  77842. set onMaterialLoaded(callback: (material: Material) => void);
  77843. /**
  77844. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  77845. */
  77846. readonly onCameraLoadedObservable: Observable<Camera>;
  77847. private _onCameraLoadedObserver;
  77848. /**
  77849. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  77850. */
  77851. set onCameraLoaded(callback: (camera: Camera) => void);
  77852. /**
  77853. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  77854. * For assets with LODs, raised when all of the LODs are complete.
  77855. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77856. */
  77857. readonly onCompleteObservable: Observable<void>;
  77858. private _onCompleteObserver;
  77859. /**
  77860. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  77861. * For assets with LODs, raised when all of the LODs are complete.
  77862. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77863. */
  77864. set onComplete(callback: () => void);
  77865. /**
  77866. * Observable raised when an error occurs.
  77867. */
  77868. readonly onErrorObservable: Observable<any>;
  77869. private _onErrorObserver;
  77870. /**
  77871. * Callback raised when an error occurs.
  77872. */
  77873. set onError(callback: (reason: any) => void);
  77874. /**
  77875. * Observable raised after the loader is disposed.
  77876. */
  77877. readonly onDisposeObservable: Observable<void>;
  77878. private _onDisposeObserver;
  77879. /**
  77880. * Callback raised after the loader is disposed.
  77881. */
  77882. set onDispose(callback: () => void);
  77883. /**
  77884. * Observable raised after a loader extension is created.
  77885. * Set additional options for a loader extension in this event.
  77886. */
  77887. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  77888. private _onExtensionLoadedObserver;
  77889. /**
  77890. * Callback raised after a loader extension is created.
  77891. */
  77892. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  77893. /**
  77894. * Defines if the loader logging is enabled.
  77895. */
  77896. get loggingEnabled(): boolean;
  77897. set loggingEnabled(value: boolean);
  77898. /**
  77899. * Defines if the loader should capture performance counters.
  77900. */
  77901. get capturePerformanceCounters(): boolean;
  77902. set capturePerformanceCounters(value: boolean);
  77903. /**
  77904. * Defines if the loader should validate the asset.
  77905. */
  77906. validate: boolean;
  77907. /**
  77908. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  77909. */
  77910. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  77911. private _onValidatedObserver;
  77912. /**
  77913. * Callback raised after a loader extension is created.
  77914. */
  77915. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  77916. private _loader;
  77917. /**
  77918. * Name of the loader ("gltf")
  77919. */
  77920. name: string;
  77921. /** @hidden */
  77922. extensions: ISceneLoaderPluginExtensions;
  77923. /**
  77924. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  77925. */
  77926. dispose(): void;
  77927. /** @hidden */
  77928. _clear(): void;
  77929. /** @hidden */
  77930. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  77931. /** @hidden */
  77932. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  77933. /** @hidden */
  77934. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77935. meshes: AbstractMesh[];
  77936. particleSystems: IParticleSystem[];
  77937. skeletons: Skeleton[];
  77938. animationGroups: AnimationGroup[];
  77939. }>;
  77940. /** @hidden */
  77941. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77942. /** @hidden */
  77943. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77944. /** @hidden */
  77945. canDirectLoad(data: string): boolean;
  77946. /** @hidden */
  77947. directLoad(scene: Scene, data: string): any;
  77948. /**
  77949. * The callback that allows custom handling of the root url based on the response url.
  77950. * @param rootUrl the original root url
  77951. * @param responseURL the response url if available
  77952. * @returns the new root url
  77953. */
  77954. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  77955. /** @hidden */
  77956. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  77957. /**
  77958. * The loader state or null if the loader is not active.
  77959. */
  77960. get loaderState(): Nullable<GLTFLoaderState>;
  77961. /**
  77962. * Returns a promise that resolves when the asset is completely loaded.
  77963. * @returns a promise that resolves when the asset is completely loaded.
  77964. */
  77965. whenCompleteAsync(): Promise<void>;
  77966. private _validate;
  77967. private _getLoader;
  77968. private _parseJson;
  77969. private _unpackBinaryAsync;
  77970. private _unpackBinaryV1Async;
  77971. private _unpackBinaryV2Async;
  77972. private static _parseVersion;
  77973. private static _compareVersion;
  77974. private static readonly _logSpaces;
  77975. private _logIndentLevel;
  77976. private _loggingEnabled;
  77977. /** @hidden */
  77978. _log: (message: string) => void;
  77979. /** @hidden */
  77980. _logOpen(message: string): void;
  77981. /** @hidden */
  77982. _logClose(): void;
  77983. private _logEnabled;
  77984. private _logDisabled;
  77985. private _capturePerformanceCounters;
  77986. /** @hidden */
  77987. _startPerformanceCounter: (counterName: string) => void;
  77988. /** @hidden */
  77989. _endPerformanceCounter: (counterName: string) => void;
  77990. private _startPerformanceCounterEnabled;
  77991. private _startPerformanceCounterDisabled;
  77992. private _endPerformanceCounterEnabled;
  77993. private _endPerformanceCounterDisabled;
  77994. }
  77995. }
  77996. declare module BABYLON.GLTF1 {
  77997. /**
  77998. * Enums
  77999. * @hidden
  78000. */
  78001. export enum EComponentType {
  78002. BYTE = 5120,
  78003. UNSIGNED_BYTE = 5121,
  78004. SHORT = 5122,
  78005. UNSIGNED_SHORT = 5123,
  78006. FLOAT = 5126
  78007. }
  78008. /** @hidden */
  78009. export enum EShaderType {
  78010. FRAGMENT = 35632,
  78011. VERTEX = 35633
  78012. }
  78013. /** @hidden */
  78014. export enum EParameterType {
  78015. BYTE = 5120,
  78016. UNSIGNED_BYTE = 5121,
  78017. SHORT = 5122,
  78018. UNSIGNED_SHORT = 5123,
  78019. INT = 5124,
  78020. UNSIGNED_INT = 5125,
  78021. FLOAT = 5126,
  78022. FLOAT_VEC2 = 35664,
  78023. FLOAT_VEC3 = 35665,
  78024. FLOAT_VEC4 = 35666,
  78025. INT_VEC2 = 35667,
  78026. INT_VEC3 = 35668,
  78027. INT_VEC4 = 35669,
  78028. BOOL = 35670,
  78029. BOOL_VEC2 = 35671,
  78030. BOOL_VEC3 = 35672,
  78031. BOOL_VEC4 = 35673,
  78032. FLOAT_MAT2 = 35674,
  78033. FLOAT_MAT3 = 35675,
  78034. FLOAT_MAT4 = 35676,
  78035. SAMPLER_2D = 35678
  78036. }
  78037. /** @hidden */
  78038. export enum ETextureWrapMode {
  78039. CLAMP_TO_EDGE = 33071,
  78040. MIRRORED_REPEAT = 33648,
  78041. REPEAT = 10497
  78042. }
  78043. /** @hidden */
  78044. export enum ETextureFilterType {
  78045. NEAREST = 9728,
  78046. LINEAR = 9728,
  78047. NEAREST_MIPMAP_NEAREST = 9984,
  78048. LINEAR_MIPMAP_NEAREST = 9985,
  78049. NEAREST_MIPMAP_LINEAR = 9986,
  78050. LINEAR_MIPMAP_LINEAR = 9987
  78051. }
  78052. /** @hidden */
  78053. export enum ETextureFormat {
  78054. ALPHA = 6406,
  78055. RGB = 6407,
  78056. RGBA = 6408,
  78057. LUMINANCE = 6409,
  78058. LUMINANCE_ALPHA = 6410
  78059. }
  78060. /** @hidden */
  78061. export enum ECullingType {
  78062. FRONT = 1028,
  78063. BACK = 1029,
  78064. FRONT_AND_BACK = 1032
  78065. }
  78066. /** @hidden */
  78067. export enum EBlendingFunction {
  78068. ZERO = 0,
  78069. ONE = 1,
  78070. SRC_COLOR = 768,
  78071. ONE_MINUS_SRC_COLOR = 769,
  78072. DST_COLOR = 774,
  78073. ONE_MINUS_DST_COLOR = 775,
  78074. SRC_ALPHA = 770,
  78075. ONE_MINUS_SRC_ALPHA = 771,
  78076. DST_ALPHA = 772,
  78077. ONE_MINUS_DST_ALPHA = 773,
  78078. CONSTANT_COLOR = 32769,
  78079. ONE_MINUS_CONSTANT_COLOR = 32770,
  78080. CONSTANT_ALPHA = 32771,
  78081. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78082. SRC_ALPHA_SATURATE = 776
  78083. }
  78084. /** @hidden */
  78085. export interface IGLTFProperty {
  78086. extensions?: {
  78087. [key: string]: any;
  78088. };
  78089. extras?: Object;
  78090. }
  78091. /** @hidden */
  78092. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78093. name?: string;
  78094. }
  78095. /** @hidden */
  78096. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78097. bufferView: string;
  78098. byteOffset: number;
  78099. byteStride: number;
  78100. count: number;
  78101. type: string;
  78102. componentType: EComponentType;
  78103. max?: number[];
  78104. min?: number[];
  78105. name?: string;
  78106. }
  78107. /** @hidden */
  78108. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78109. buffer: string;
  78110. byteOffset: number;
  78111. byteLength: number;
  78112. byteStride: number;
  78113. target?: number;
  78114. }
  78115. /** @hidden */
  78116. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78117. uri: string;
  78118. byteLength?: number;
  78119. type?: string;
  78120. }
  78121. /** @hidden */
  78122. export interface IGLTFShader extends IGLTFChildRootProperty {
  78123. uri: string;
  78124. type: EShaderType;
  78125. }
  78126. /** @hidden */
  78127. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78128. attributes: string[];
  78129. fragmentShader: string;
  78130. vertexShader: string;
  78131. }
  78132. /** @hidden */
  78133. export interface IGLTFTechniqueParameter {
  78134. type: number;
  78135. count?: number;
  78136. semantic?: string;
  78137. node?: string;
  78138. value?: number | boolean | string | Array<any>;
  78139. source?: string;
  78140. babylonValue?: any;
  78141. }
  78142. /** @hidden */
  78143. export interface IGLTFTechniqueCommonProfile {
  78144. lightingModel: string;
  78145. texcoordBindings: Object;
  78146. parameters?: Array<any>;
  78147. }
  78148. /** @hidden */
  78149. export interface IGLTFTechniqueStatesFunctions {
  78150. blendColor?: number[];
  78151. blendEquationSeparate?: number[];
  78152. blendFuncSeparate?: number[];
  78153. colorMask: boolean[];
  78154. cullFace: number[];
  78155. }
  78156. /** @hidden */
  78157. export interface IGLTFTechniqueStates {
  78158. enable: number[];
  78159. functions: IGLTFTechniqueStatesFunctions;
  78160. }
  78161. /** @hidden */
  78162. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78163. parameters: {
  78164. [key: string]: IGLTFTechniqueParameter;
  78165. };
  78166. program: string;
  78167. attributes: {
  78168. [key: string]: string;
  78169. };
  78170. uniforms: {
  78171. [key: string]: string;
  78172. };
  78173. states: IGLTFTechniqueStates;
  78174. }
  78175. /** @hidden */
  78176. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78177. technique?: string;
  78178. values: string[];
  78179. }
  78180. /** @hidden */
  78181. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78182. attributes: {
  78183. [key: string]: string;
  78184. };
  78185. indices: string;
  78186. material: string;
  78187. mode?: number;
  78188. }
  78189. /** @hidden */
  78190. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78191. primitives: IGLTFMeshPrimitive[];
  78192. }
  78193. /** @hidden */
  78194. export interface IGLTFImage extends IGLTFChildRootProperty {
  78195. uri: string;
  78196. }
  78197. /** @hidden */
  78198. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78199. magFilter?: number;
  78200. minFilter?: number;
  78201. wrapS?: number;
  78202. wrapT?: number;
  78203. }
  78204. /** @hidden */
  78205. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78206. sampler: string;
  78207. source: string;
  78208. format?: ETextureFormat;
  78209. internalFormat?: ETextureFormat;
  78210. target?: number;
  78211. type?: number;
  78212. babylonTexture?: Texture;
  78213. }
  78214. /** @hidden */
  78215. export interface IGLTFAmbienLight {
  78216. color?: number[];
  78217. }
  78218. /** @hidden */
  78219. export interface IGLTFDirectionalLight {
  78220. color?: number[];
  78221. }
  78222. /** @hidden */
  78223. export interface IGLTFPointLight {
  78224. color?: number[];
  78225. constantAttenuation?: number;
  78226. linearAttenuation?: number;
  78227. quadraticAttenuation?: number;
  78228. }
  78229. /** @hidden */
  78230. export interface IGLTFSpotLight {
  78231. color?: number[];
  78232. constantAttenuation?: number;
  78233. fallOfAngle?: number;
  78234. fallOffExponent?: number;
  78235. linearAttenuation?: number;
  78236. quadraticAttenuation?: number;
  78237. }
  78238. /** @hidden */
  78239. export interface IGLTFLight extends IGLTFChildRootProperty {
  78240. type: string;
  78241. }
  78242. /** @hidden */
  78243. export interface IGLTFCameraOrthographic {
  78244. xmag: number;
  78245. ymag: number;
  78246. zfar: number;
  78247. znear: number;
  78248. }
  78249. /** @hidden */
  78250. export interface IGLTFCameraPerspective {
  78251. aspectRatio: number;
  78252. yfov: number;
  78253. zfar: number;
  78254. znear: number;
  78255. }
  78256. /** @hidden */
  78257. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78258. type: string;
  78259. }
  78260. /** @hidden */
  78261. export interface IGLTFAnimationChannelTarget {
  78262. id: string;
  78263. path: string;
  78264. }
  78265. /** @hidden */
  78266. export interface IGLTFAnimationChannel {
  78267. sampler: string;
  78268. target: IGLTFAnimationChannelTarget;
  78269. }
  78270. /** @hidden */
  78271. export interface IGLTFAnimationSampler {
  78272. input: string;
  78273. output: string;
  78274. interpolation?: string;
  78275. }
  78276. /** @hidden */
  78277. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78278. channels?: IGLTFAnimationChannel[];
  78279. parameters?: {
  78280. [key: string]: string;
  78281. };
  78282. samplers?: {
  78283. [key: string]: IGLTFAnimationSampler;
  78284. };
  78285. }
  78286. /** @hidden */
  78287. export interface IGLTFNodeInstanceSkin {
  78288. skeletons: string[];
  78289. skin: string;
  78290. meshes: string[];
  78291. }
  78292. /** @hidden */
  78293. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78294. bindShapeMatrix: number[];
  78295. inverseBindMatrices: string;
  78296. jointNames: string[];
  78297. babylonSkeleton?: Skeleton;
  78298. }
  78299. /** @hidden */
  78300. export interface IGLTFNode extends IGLTFChildRootProperty {
  78301. camera?: string;
  78302. children: string[];
  78303. skin?: string;
  78304. jointName?: string;
  78305. light?: string;
  78306. matrix: number[];
  78307. mesh?: string;
  78308. meshes?: string[];
  78309. rotation?: number[];
  78310. scale?: number[];
  78311. translation?: number[];
  78312. babylonNode?: Node;
  78313. }
  78314. /** @hidden */
  78315. export interface IGLTFScene extends IGLTFChildRootProperty {
  78316. nodes: string[];
  78317. }
  78318. /** @hidden */
  78319. export interface IGLTFRuntime {
  78320. extensions: {
  78321. [key: string]: any;
  78322. };
  78323. accessors: {
  78324. [key: string]: IGLTFAccessor;
  78325. };
  78326. buffers: {
  78327. [key: string]: IGLTFBuffer;
  78328. };
  78329. bufferViews: {
  78330. [key: string]: IGLTFBufferView;
  78331. };
  78332. meshes: {
  78333. [key: string]: IGLTFMesh;
  78334. };
  78335. lights: {
  78336. [key: string]: IGLTFLight;
  78337. };
  78338. cameras: {
  78339. [key: string]: IGLTFCamera;
  78340. };
  78341. nodes: {
  78342. [key: string]: IGLTFNode;
  78343. };
  78344. images: {
  78345. [key: string]: IGLTFImage;
  78346. };
  78347. textures: {
  78348. [key: string]: IGLTFTexture;
  78349. };
  78350. shaders: {
  78351. [key: string]: IGLTFShader;
  78352. };
  78353. programs: {
  78354. [key: string]: IGLTFProgram;
  78355. };
  78356. samplers: {
  78357. [key: string]: IGLTFSampler;
  78358. };
  78359. techniques: {
  78360. [key: string]: IGLTFTechnique;
  78361. };
  78362. materials: {
  78363. [key: string]: IGLTFMaterial;
  78364. };
  78365. animations: {
  78366. [key: string]: IGLTFAnimation;
  78367. };
  78368. skins: {
  78369. [key: string]: IGLTFSkins;
  78370. };
  78371. currentScene?: Object;
  78372. scenes: {
  78373. [key: string]: IGLTFScene;
  78374. };
  78375. extensionsUsed: string[];
  78376. extensionsRequired?: string[];
  78377. buffersCount: number;
  78378. shaderscount: number;
  78379. scene: Scene;
  78380. rootUrl: string;
  78381. loadedBufferCount: number;
  78382. loadedBufferViews: {
  78383. [name: string]: ArrayBufferView;
  78384. };
  78385. loadedShaderCount: number;
  78386. importOnlyMeshes: boolean;
  78387. importMeshesNames?: string[];
  78388. dummyNodes: Node[];
  78389. forAssetContainer: boolean;
  78390. }
  78391. /** @hidden */
  78392. export interface INodeToRoot {
  78393. bone: Bone;
  78394. node: IGLTFNode;
  78395. id: string;
  78396. }
  78397. /** @hidden */
  78398. export interface IJointNode {
  78399. node: IGLTFNode;
  78400. id: string;
  78401. }
  78402. }
  78403. declare module BABYLON.GLTF1 {
  78404. /**
  78405. * Utils functions for GLTF
  78406. * @hidden
  78407. */
  78408. export class GLTFUtils {
  78409. /**
  78410. * Sets the given "parameter" matrix
  78411. * @param scene: the Scene object
  78412. * @param source: the source node where to pick the matrix
  78413. * @param parameter: the GLTF technique parameter
  78414. * @param uniformName: the name of the shader's uniform
  78415. * @param shaderMaterial: the shader material
  78416. */
  78417. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  78418. /**
  78419. * Sets the given "parameter" matrix
  78420. * @param shaderMaterial: the shader material
  78421. * @param uniform: the name of the shader's uniform
  78422. * @param value: the value of the uniform
  78423. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  78424. */
  78425. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  78426. /**
  78427. * Returns the wrap mode of the texture
  78428. * @param mode: the mode value
  78429. */
  78430. static GetWrapMode(mode: number): number;
  78431. /**
  78432. * Returns the byte stride giving an accessor
  78433. * @param accessor: the GLTF accessor objet
  78434. */
  78435. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  78436. /**
  78437. * Returns the texture filter mode giving a mode value
  78438. * @param mode: the filter mode value
  78439. */
  78440. static GetTextureFilterMode(mode: number): ETextureFilterType;
  78441. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  78442. /**
  78443. * Returns a buffer from its accessor
  78444. * @param gltfRuntime: the GLTF runtime
  78445. * @param accessor: the GLTF accessor
  78446. */
  78447. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  78448. /**
  78449. * Decodes a buffer view into a string
  78450. * @param view: the buffer view
  78451. */
  78452. static DecodeBufferToText(view: ArrayBufferView): string;
  78453. /**
  78454. * Returns the default material of gltf. Related to
  78455. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  78456. * @param scene: the Babylon.js scene
  78457. */
  78458. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  78459. private static _DefaultMaterial;
  78460. }
  78461. }
  78462. declare module BABYLON.GLTF1 {
  78463. /**
  78464. * Implementation of the base glTF spec
  78465. * @hidden
  78466. */
  78467. export class GLTFLoaderBase {
  78468. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  78469. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78470. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  78471. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78472. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  78473. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78474. }
  78475. /**
  78476. * glTF V1 Loader
  78477. * @hidden
  78478. */
  78479. export class GLTFLoader implements IGLTFLoader {
  78480. static Extensions: {
  78481. [name: string]: GLTFLoaderExtension;
  78482. };
  78483. static RegisterExtension(extension: GLTFLoaderExtension): void;
  78484. state: Nullable<GLTFLoaderState>;
  78485. dispose(): void;
  78486. private _importMeshAsync;
  78487. /**
  78488. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  78489. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78490. * @param scene the scene the meshes should be added to
  78491. * @param forAssetContainer defines if the entities must be stored in the scene
  78492. * @param data gltf data containing information of the meshes in a loaded file
  78493. * @param rootUrl root url to load from
  78494. * @param onProgress event that fires when loading progress has occured
  78495. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78496. */
  78497. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  78498. private _loadAsync;
  78499. /**
  78500. * Imports all objects from a loaded gltf file and adds them to the scene
  78501. * @param scene the scene the objects should be added to
  78502. * @param data gltf data containing information of the meshes in a loaded file
  78503. * @param rootUrl root url to load from
  78504. * @param onProgress event that fires when loading progress has occured
  78505. * @returns a promise which completes when objects have been loaded to the scene
  78506. */
  78507. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  78508. private _loadShadersAsync;
  78509. private _loadBuffersAsync;
  78510. private _createNodes;
  78511. }
  78512. /** @hidden */
  78513. export abstract class GLTFLoaderExtension {
  78514. private _name;
  78515. constructor(name: string);
  78516. get name(): string;
  78517. /**
  78518. * Defines an override for loading the runtime
  78519. * Return true to stop further extensions from loading the runtime
  78520. */
  78521. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  78522. /**
  78523. * Defines an onverride for creating gltf runtime
  78524. * Return true to stop further extensions from creating the runtime
  78525. */
  78526. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  78527. /**
  78528. * Defines an override for loading buffers
  78529. * Return true to stop further extensions from loading this buffer
  78530. */
  78531. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  78532. /**
  78533. * Defines an override for loading texture buffers
  78534. * Return true to stop further extensions from loading this texture data
  78535. */
  78536. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78537. /**
  78538. * Defines an override for creating textures
  78539. * Return true to stop further extensions from loading this texture
  78540. */
  78541. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  78542. /**
  78543. * Defines an override for loading shader strings
  78544. * Return true to stop further extensions from loading this shader data
  78545. */
  78546. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78547. /**
  78548. * Defines an override for loading materials
  78549. * Return true to stop further extensions from loading this material
  78550. */
  78551. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78552. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  78553. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  78554. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78555. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78556. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  78557. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78558. private static LoadTextureBufferAsync;
  78559. private static CreateTextureAsync;
  78560. private static ApplyExtensions;
  78561. }
  78562. }
  78563. declare module BABYLON.GLTF1 {
  78564. /** @hidden */
  78565. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  78566. private _bin;
  78567. constructor();
  78568. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  78569. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78570. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78571. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78572. }
  78573. }
  78574. declare module BABYLON.GLTF1 {
  78575. /** @hidden */
  78576. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  78577. constructor();
  78578. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  78579. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78580. private _loadTexture;
  78581. }
  78582. }
  78583. declare module BABYLON.GLTF2.Loader {
  78584. /**
  78585. * Loader interface with an index field.
  78586. */
  78587. export interface IArrayItem {
  78588. /**
  78589. * The index of this item in the array.
  78590. */
  78591. index: number;
  78592. }
  78593. /**
  78594. * Loader interface with additional members.
  78595. */
  78596. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  78597. /** @hidden */
  78598. _data?: Promise<ArrayBufferView>;
  78599. /** @hidden */
  78600. _babylonVertexBuffer?: Promise<VertexBuffer>;
  78601. }
  78602. /**
  78603. * Loader interface with additional members.
  78604. */
  78605. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  78606. }
  78607. /** @hidden */
  78608. export interface _IAnimationSamplerData {
  78609. input: Float32Array;
  78610. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  78611. output: Float32Array;
  78612. }
  78613. /**
  78614. * Loader interface with additional members.
  78615. */
  78616. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  78617. /** @hidden */
  78618. _data?: Promise<_IAnimationSamplerData>;
  78619. }
  78620. /**
  78621. * Loader interface with additional members.
  78622. */
  78623. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  78624. channels: IAnimationChannel[];
  78625. samplers: IAnimationSampler[];
  78626. /** @hidden */
  78627. _babylonAnimationGroup?: AnimationGroup;
  78628. }
  78629. /**
  78630. * Loader interface with additional members.
  78631. */
  78632. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  78633. /** @hidden */
  78634. _data?: Promise<ArrayBufferView>;
  78635. }
  78636. /**
  78637. * Loader interface with additional members.
  78638. */
  78639. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  78640. /** @hidden */
  78641. _data?: Promise<ArrayBufferView>;
  78642. /** @hidden */
  78643. _babylonBuffer?: Promise<Buffer>;
  78644. }
  78645. /**
  78646. * Loader interface with additional members.
  78647. */
  78648. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  78649. }
  78650. /**
  78651. * Loader interface with additional members.
  78652. */
  78653. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  78654. /** @hidden */
  78655. _data?: Promise<ArrayBufferView>;
  78656. }
  78657. /**
  78658. * Loader interface with additional members.
  78659. */
  78660. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  78661. }
  78662. /**
  78663. * Loader interface with additional members.
  78664. */
  78665. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  78666. }
  78667. /**
  78668. * Loader interface with additional members.
  78669. */
  78670. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  78671. baseColorTexture?: ITextureInfo;
  78672. metallicRoughnessTexture?: ITextureInfo;
  78673. }
  78674. /**
  78675. * Loader interface with additional members.
  78676. */
  78677. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  78678. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78679. normalTexture?: IMaterialNormalTextureInfo;
  78680. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78681. emissiveTexture?: ITextureInfo;
  78682. /** @hidden */
  78683. _data?: {
  78684. [babylonDrawMode: number]: {
  78685. babylonMaterial: Material;
  78686. babylonMeshes: AbstractMesh[];
  78687. promise: Promise<void>;
  78688. };
  78689. };
  78690. }
  78691. /**
  78692. * Loader interface with additional members.
  78693. */
  78694. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  78695. primitives: IMeshPrimitive[];
  78696. }
  78697. /**
  78698. * Loader interface with additional members.
  78699. */
  78700. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  78701. /** @hidden */
  78702. _instanceData?: {
  78703. babylonSourceMesh: Mesh;
  78704. promise: Promise<any>;
  78705. };
  78706. }
  78707. /**
  78708. * Loader interface with additional members.
  78709. */
  78710. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  78711. /**
  78712. * The parent glTF node.
  78713. */
  78714. parent?: INode;
  78715. /** @hidden */
  78716. _babylonTransformNode?: TransformNode;
  78717. /** @hidden */
  78718. _primitiveBabylonMeshes?: AbstractMesh[];
  78719. /** @hidden */
  78720. _babylonBones?: Bone[];
  78721. /** @hidden */
  78722. _numMorphTargets?: number;
  78723. }
  78724. /** @hidden */
  78725. export interface _ISamplerData {
  78726. noMipMaps: boolean;
  78727. samplingMode: number;
  78728. wrapU: number;
  78729. wrapV: number;
  78730. }
  78731. /**
  78732. * Loader interface with additional members.
  78733. */
  78734. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  78735. /** @hidden */
  78736. _data?: _ISamplerData;
  78737. }
  78738. /**
  78739. * Loader interface with additional members.
  78740. */
  78741. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  78742. }
  78743. /**
  78744. * Loader interface with additional members.
  78745. */
  78746. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  78747. /** @hidden */
  78748. _data?: {
  78749. babylonSkeleton: Skeleton;
  78750. promise: Promise<void>;
  78751. };
  78752. }
  78753. /**
  78754. * Loader interface with additional members.
  78755. */
  78756. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  78757. }
  78758. /**
  78759. * Loader interface with additional members.
  78760. */
  78761. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  78762. }
  78763. /**
  78764. * Loader interface with additional members.
  78765. */
  78766. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  78767. accessors?: IAccessor[];
  78768. animations?: IAnimation[];
  78769. buffers?: IBuffer[];
  78770. bufferViews?: IBufferView[];
  78771. cameras?: ICamera[];
  78772. images?: IImage[];
  78773. materials?: IMaterial[];
  78774. meshes?: IMesh[];
  78775. nodes?: INode[];
  78776. samplers?: ISampler[];
  78777. scenes?: IScene[];
  78778. skins?: ISkin[];
  78779. textures?: ITexture[];
  78780. }
  78781. }
  78782. declare module BABYLON.GLTF2 {
  78783. /**
  78784. * Interface for a glTF loader extension.
  78785. */
  78786. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  78787. /**
  78788. * Called after the loader state changes to LOADING.
  78789. */
  78790. onLoading?(): void;
  78791. /**
  78792. * Called after the loader state changes to READY.
  78793. */
  78794. onReady?(): void;
  78795. /**
  78796. * Define this method to modify the default behavior when loading scenes.
  78797. * @param context The context when loading the asset
  78798. * @param scene The glTF scene property
  78799. * @returns A promise that resolves when the load is complete or null if not handled
  78800. */
  78801. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  78802. /**
  78803. * Define this method to modify the default behavior when loading nodes.
  78804. * @param context The context when loading the asset
  78805. * @param node The glTF node property
  78806. * @param assign A function called synchronously after parsing the glTF properties
  78807. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  78808. */
  78809. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78810. /**
  78811. * Define this method to modify the default behavior when loading cameras.
  78812. * @param context The context when loading the asset
  78813. * @param camera The glTF camera property
  78814. * @param assign A function called synchronously after parsing the glTF properties
  78815. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  78816. */
  78817. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  78818. /**
  78819. * @hidden
  78820. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  78821. * @param context The context when loading the asset
  78822. * @param primitive The glTF mesh primitive property
  78823. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  78824. */
  78825. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  78826. /**
  78827. * @hidden
  78828. * Define this method to modify the default behavior when loading data for mesh primitives.
  78829. * @param context The context when loading the asset
  78830. * @param name The mesh name when loading the asset
  78831. * @param node The glTF node when loading the asset
  78832. * @param mesh The glTF mesh when loading the asset
  78833. * @param primitive The glTF mesh primitive property
  78834. * @param assign A function called synchronously after parsing the glTF properties
  78835. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  78836. */
  78837. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  78838. /**
  78839. * @hidden
  78840. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  78841. * @param context The context when loading the asset
  78842. * @param material The glTF material property
  78843. * @param assign A function called synchronously after parsing the glTF properties
  78844. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  78845. */
  78846. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  78847. /**
  78848. * Define this method to modify the default behavior when creating materials.
  78849. * @param context The context when loading the asset
  78850. * @param material The glTF material property
  78851. * @param babylonDrawMode The draw mode for the Babylon material
  78852. * @returns The Babylon material or null if not handled
  78853. */
  78854. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  78855. /**
  78856. * Define this method to modify the default behavior when loading material properties.
  78857. * @param context The context when loading the asset
  78858. * @param material The glTF material property
  78859. * @param babylonMaterial The Babylon material
  78860. * @returns A promise that resolves when the load is complete or null if not handled
  78861. */
  78862. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78863. /**
  78864. * Define this method to modify the default behavior when loading texture infos.
  78865. * @param context The context when loading the asset
  78866. * @param textureInfo The glTF texture info 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. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78871. /**
  78872. * @hidden
  78873. * Define this method to modify the default behavior when loading textures.
  78874. * @param context The context when loading the asset
  78875. * @param texture The glTF texture property
  78876. * @param assign A function called synchronously after parsing the glTF properties
  78877. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  78878. */
  78879. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78880. /**
  78881. * Define this method to modify the default behavior when loading animations.
  78882. * @param context The context when loading the asset
  78883. * @param animation The glTF animation property
  78884. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  78885. */
  78886. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  78887. /**
  78888. * @hidden
  78889. * Define this method to modify the default behavior when loading skins.
  78890. * @param context The context when loading the asset
  78891. * @param node The glTF node property
  78892. * @param skin The glTF skin property
  78893. * @returns A promise that resolves when the load is complete or null if not handled
  78894. */
  78895. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  78896. /**
  78897. * @hidden
  78898. * Define this method to modify the default behavior when loading uris.
  78899. * @param context The context when loading the asset
  78900. * @param property The glTF property associated with the uri
  78901. * @param uri The uri to load
  78902. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78903. */
  78904. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  78905. /**
  78906. * Define this method to modify the default behavior when loading buffer views.
  78907. * @param context The context when loading the asset
  78908. * @param bufferView The glTF buffer view property
  78909. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78910. */
  78911. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  78912. /**
  78913. * Define this method to modify the default behavior when loading buffers.
  78914. * @param context The context when loading the asset
  78915. * @param buffer The glTF buffer property
  78916. * @param byteOffset The byte offset to load
  78917. * @param byteLength The byte length to load
  78918. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78919. */
  78920. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  78921. }
  78922. }
  78923. declare module BABYLON.GLTF2 {
  78924. /**
  78925. * Helper class for working with arrays when loading the glTF asset
  78926. */
  78927. export class ArrayItem {
  78928. /**
  78929. * Gets an item from the given array.
  78930. * @param context The context when loading the asset
  78931. * @param array The array to get the item from
  78932. * @param index The index to the array
  78933. * @returns The array item
  78934. */
  78935. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  78936. /**
  78937. * Assign an `index` field to each item of the given array.
  78938. * @param array The array of items
  78939. */
  78940. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  78941. }
  78942. /**
  78943. * The glTF 2.0 loader
  78944. */
  78945. export class GLTFLoader implements IGLTFLoader {
  78946. /** @hidden */
  78947. _completePromises: Promise<any>[];
  78948. /** @hidden */
  78949. _forAssetContainer: boolean;
  78950. /** Storage */
  78951. _babylonLights: Light[];
  78952. private _disposed;
  78953. private _parent;
  78954. private _state;
  78955. private _extensions;
  78956. private _rootUrl;
  78957. private _fileName;
  78958. private _uniqueRootUrl;
  78959. private _gltf;
  78960. private _bin;
  78961. private _babylonScene;
  78962. private _rootBabylonMesh;
  78963. private _defaultBabylonMaterialData;
  78964. private _progressCallback?;
  78965. private _requests;
  78966. private static _RegisteredExtensions;
  78967. /**
  78968. * The default glTF sampler.
  78969. */
  78970. static readonly DefaultSampler: ISampler;
  78971. /**
  78972. * Registers a loader extension.
  78973. * @param name The name of the loader extension.
  78974. * @param factory The factory function that creates the loader extension.
  78975. */
  78976. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  78977. /**
  78978. * Unregisters a loader extension.
  78979. * @param name The name of the loader extension.
  78980. * @returns A boolean indicating whether the extension has been unregistered
  78981. */
  78982. static UnregisterExtension(name: string): boolean;
  78983. /**
  78984. * The loader state.
  78985. */
  78986. get state(): Nullable<GLTFLoaderState>;
  78987. /**
  78988. * The object that represents the glTF JSON.
  78989. */
  78990. get gltf(): IGLTF;
  78991. /**
  78992. * The BIN chunk of a binary glTF.
  78993. */
  78994. get bin(): Nullable<IDataBuffer>;
  78995. /**
  78996. * The parent file loader.
  78997. */
  78998. get parent(): GLTFFileLoader;
  78999. /**
  79000. * The Babylon scene when loading the asset.
  79001. */
  79002. get babylonScene(): Scene;
  79003. /**
  79004. * The root Babylon mesh when loading the asset.
  79005. */
  79006. get rootBabylonMesh(): Mesh;
  79007. /** @hidden */
  79008. constructor(parent: GLTFFileLoader);
  79009. /** @hidden */
  79010. dispose(): void;
  79011. /** @hidden */
  79012. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  79013. /** @hidden */
  79014. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79015. private _loadAsync;
  79016. private _loadData;
  79017. private _setupData;
  79018. private _loadExtensions;
  79019. private _checkExtensions;
  79020. private _setState;
  79021. private _createRootNode;
  79022. /**
  79023. * Loads a glTF scene.
  79024. * @param context The context when loading the asset
  79025. * @param scene The glTF scene property
  79026. * @returns A promise that resolves when the load is complete
  79027. */
  79028. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  79029. private _forEachPrimitive;
  79030. private _getMeshes;
  79031. private _getTransformNodes;
  79032. private _getSkeletons;
  79033. private _getAnimationGroups;
  79034. private _startAnimations;
  79035. /**
  79036. * Loads a glTF node.
  79037. * @param context The context when loading the asset
  79038. * @param node The glTF node property
  79039. * @param assign A function called synchronously after parsing the glTF properties
  79040. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79041. */
  79042. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79043. private _loadMeshAsync;
  79044. /**
  79045. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79046. * @param context The context when loading the asset
  79047. * @param name The mesh name when loading the asset
  79048. * @param node The glTF node when loading the asset
  79049. * @param mesh The glTF mesh when loading the asset
  79050. * @param primitive The glTF mesh primitive property
  79051. * @param assign A function called synchronously after parsing the glTF properties
  79052. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79053. */
  79054. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79055. private _loadVertexDataAsync;
  79056. private _createMorphTargets;
  79057. private _loadMorphTargetsAsync;
  79058. private _loadMorphTargetVertexDataAsync;
  79059. private static _LoadTransform;
  79060. private _loadSkinAsync;
  79061. private _loadBones;
  79062. private _loadBone;
  79063. private _loadSkinInverseBindMatricesDataAsync;
  79064. private _updateBoneMatrices;
  79065. private _getNodeMatrix;
  79066. /**
  79067. * Loads a glTF camera.
  79068. * @param context The context when loading the asset
  79069. * @param camera The glTF camera property
  79070. * @param assign A function called synchronously after parsing the glTF properties
  79071. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79072. */
  79073. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79074. private _loadAnimationsAsync;
  79075. /**
  79076. * Loads a glTF animation.
  79077. * @param context The context when loading the asset
  79078. * @param animation The glTF animation property
  79079. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79080. */
  79081. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79082. /**
  79083. * @hidden Loads a glTF animation channel.
  79084. * @param context The context when loading the asset
  79085. * @param animationContext The context of the animation when loading the asset
  79086. * @param animation The glTF animation property
  79087. * @param channel The glTF animation channel property
  79088. * @param babylonAnimationGroup The babylon animation group property
  79089. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79090. * @returns A void promise when the channel load is complete
  79091. */
  79092. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79093. private _loadAnimationSamplerAsync;
  79094. private _loadBufferAsync;
  79095. /**
  79096. * Loads a glTF buffer view.
  79097. * @param context The context when loading the asset
  79098. * @param bufferView The glTF buffer view property
  79099. * @returns A promise that resolves with the loaded data when the load is complete
  79100. */
  79101. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79102. private _loadAccessorAsync;
  79103. /** @hidden */
  79104. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79105. private _loadIndicesAccessorAsync;
  79106. private _loadVertexBufferViewAsync;
  79107. private _loadVertexAccessorAsync;
  79108. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79109. /** @hidden */
  79110. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79111. private _createDefaultMaterial;
  79112. /**
  79113. * Creates a Babylon material from a glTF material.
  79114. * @param context The context when loading the asset
  79115. * @param material The glTF material property
  79116. * @param babylonDrawMode The draw mode for the Babylon material
  79117. * @returns The Babylon material
  79118. */
  79119. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79120. /**
  79121. * Loads properties from a glTF material into a Babylon material.
  79122. * @param context The context when loading the asset
  79123. * @param material The glTF material property
  79124. * @param babylonMaterial The Babylon material
  79125. * @returns A promise that resolves when the load is complete
  79126. */
  79127. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79128. /**
  79129. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79130. * @param context The context when loading the asset
  79131. * @param material The glTF material property
  79132. * @param babylonMaterial The Babylon material
  79133. * @returns A promise that resolves when the load is complete
  79134. */
  79135. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79136. /**
  79137. * Loads the alpha properties from a glTF material into a Babylon material.
  79138. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79139. * @param context The context when loading the asset
  79140. * @param material The glTF material property
  79141. * @param babylonMaterial The Babylon material
  79142. */
  79143. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79144. /**
  79145. * Loads a glTF texture info.
  79146. * @param context The context when loading the asset
  79147. * @param textureInfo The glTF texture info property
  79148. * @param assign A function called synchronously after parsing the glTF properties
  79149. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79150. */
  79151. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79152. /** @hidden */
  79153. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79154. /** @hidden */
  79155. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79156. private _loadSampler;
  79157. /**
  79158. * Loads a glTF image.
  79159. * @param context The context when loading the asset
  79160. * @param image The glTF image property
  79161. * @returns A promise that resolves with the loaded data when the load is complete
  79162. */
  79163. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79164. /**
  79165. * Loads a glTF uri.
  79166. * @param context The context when loading the asset
  79167. * @param property The glTF property associated with the uri
  79168. * @param uri The base64 or relative uri
  79169. * @returns A promise that resolves with the loaded data when the load is complete
  79170. */
  79171. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79172. private _onProgress;
  79173. /**
  79174. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79175. * @param babylonObject the Babylon object with metadata
  79176. * @param pointer the JSON pointer
  79177. */
  79178. static AddPointerMetadata(babylonObject: {
  79179. metadata: any;
  79180. }, pointer: string): void;
  79181. private static _GetTextureWrapMode;
  79182. private static _GetTextureSamplingMode;
  79183. private static _GetTypedArrayConstructor;
  79184. private static _GetTypedArray;
  79185. private static _GetNumComponents;
  79186. private static _ValidateUri;
  79187. private static _GetDrawMode;
  79188. private _compileMaterialsAsync;
  79189. private _compileShadowGeneratorsAsync;
  79190. private _forEachExtensions;
  79191. private _applyExtensions;
  79192. private _extensionsOnLoading;
  79193. private _extensionsOnReady;
  79194. private _extensionsLoadSceneAsync;
  79195. private _extensionsLoadNodeAsync;
  79196. private _extensionsLoadCameraAsync;
  79197. private _extensionsLoadVertexDataAsync;
  79198. private _extensionsLoadMeshPrimitiveAsync;
  79199. private _extensionsLoadMaterialAsync;
  79200. private _extensionsCreateMaterial;
  79201. private _extensionsLoadMaterialPropertiesAsync;
  79202. private _extensionsLoadTextureInfoAsync;
  79203. private _extensionsLoadTextureAsync;
  79204. private _extensionsLoadAnimationAsync;
  79205. private _extensionsLoadSkinAsync;
  79206. private _extensionsLoadUriAsync;
  79207. private _extensionsLoadBufferViewAsync;
  79208. private _extensionsLoadBufferAsync;
  79209. /**
  79210. * Helper method called by a loader extension to load an glTF extension.
  79211. * @param context The context when loading the asset
  79212. * @param property The glTF property to load the extension 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 extension does not exist
  79216. */
  79217. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79218. /**
  79219. * Helper method called by a loader extension to load a glTF extra.
  79220. * @param context The context when loading the asset
  79221. * @param property The glTF property to load the extra from
  79222. * @param extensionName The name of the extension to load
  79223. * @param actionAsync The action to run
  79224. * @returns The promise returned by actionAsync or null if the extra does not exist
  79225. */
  79226. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79227. /**
  79228. * Checks for presence of an extension.
  79229. * @param name The name of the extension to check
  79230. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79231. */
  79232. isExtensionUsed(name: string): boolean;
  79233. /**
  79234. * Increments the indentation level and logs a message.
  79235. * @param message The message to log
  79236. */
  79237. logOpen(message: string): void;
  79238. /**
  79239. * Decrements the indentation level.
  79240. */
  79241. logClose(): void;
  79242. /**
  79243. * Logs a message
  79244. * @param message The message to log
  79245. */
  79246. log(message: string): void;
  79247. /**
  79248. * Starts a performance counter.
  79249. * @param counterName The name of the performance counter
  79250. */
  79251. startPerformanceCounter(counterName: string): void;
  79252. /**
  79253. * Ends a performance counter.
  79254. * @param counterName The name of the performance counter
  79255. */
  79256. endPerformanceCounter(counterName: string): void;
  79257. }
  79258. }
  79259. declare module BABYLON.GLTF2.Loader.Extensions {
  79260. /**
  79261. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79262. */
  79263. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79264. /**
  79265. * The name of this extension.
  79266. */
  79267. readonly name: string;
  79268. /**
  79269. * Defines whether this extension is enabled.
  79270. */
  79271. enabled: boolean;
  79272. private _loader;
  79273. private _lights?;
  79274. /** @hidden */
  79275. constructor(loader: GLTFLoader);
  79276. /** @hidden */
  79277. dispose(): void;
  79278. /** @hidden */
  79279. onLoading(): void;
  79280. /** @hidden */
  79281. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79282. private _loadLightAsync;
  79283. }
  79284. }
  79285. declare module BABYLON.GLTF2.Loader.Extensions {
  79286. /**
  79287. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79288. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79289. * !!! Experimental Extension Subject to Changes !!!
  79290. */
  79291. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79292. /**
  79293. * The name of this extension.
  79294. */
  79295. readonly name: string;
  79296. /**
  79297. * Defines whether this extension is enabled.
  79298. */
  79299. enabled: boolean;
  79300. private _loader;
  79301. /** @hidden */
  79302. constructor(loader: GLTFLoader);
  79303. /** @hidden */
  79304. dispose(): void;
  79305. /** @hidden */
  79306. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79307. }
  79308. }
  79309. declare module BABYLON.GLTF2.Loader.Extensions {
  79310. /**
  79311. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79312. */
  79313. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79314. /**
  79315. * The name of this extension.
  79316. */
  79317. readonly name: string;
  79318. /**
  79319. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79320. */
  79321. dracoCompression?: DracoCompression;
  79322. /**
  79323. * Defines whether this extension is enabled.
  79324. */
  79325. enabled: boolean;
  79326. private _loader;
  79327. /** @hidden */
  79328. constructor(loader: GLTFLoader);
  79329. /** @hidden */
  79330. dispose(): void;
  79331. /** @hidden */
  79332. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79333. }
  79334. }
  79335. declare module BABYLON.GLTF2.Loader.Extensions {
  79336. /**
  79337. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79338. */
  79339. export class KHR_lights implements IGLTFLoaderExtension {
  79340. /**
  79341. * The name of this extension.
  79342. */
  79343. readonly name: string;
  79344. /**
  79345. * Defines whether this extension is enabled.
  79346. */
  79347. enabled: boolean;
  79348. private _loader;
  79349. private _lights?;
  79350. /** @hidden */
  79351. constructor(loader: GLTFLoader);
  79352. /** @hidden */
  79353. dispose(): void;
  79354. /** @hidden */
  79355. onLoading(): void;
  79356. /** @hidden */
  79357. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79358. }
  79359. }
  79360. declare module BABYLON.GLTF2.Loader.Extensions {
  79361. /**
  79362. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  79363. */
  79364. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  79365. /**
  79366. * The name of this extension.
  79367. */
  79368. readonly name: string;
  79369. /**
  79370. * Defines whether this extension is enabled.
  79371. */
  79372. enabled: boolean;
  79373. /**
  79374. * Defines a number that determines the order the extensions are applied.
  79375. */
  79376. order: number;
  79377. private _loader;
  79378. /** @hidden */
  79379. constructor(loader: GLTFLoader);
  79380. /** @hidden */
  79381. dispose(): void;
  79382. /** @hidden */
  79383. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79384. private _loadSpecularGlossinessPropertiesAsync;
  79385. }
  79386. }
  79387. declare module BABYLON.GLTF2.Loader.Extensions {
  79388. /**
  79389. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  79390. */
  79391. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  79392. /**
  79393. * The name of this extension.
  79394. */
  79395. readonly name: string;
  79396. /**
  79397. * Defines whether this extension is enabled.
  79398. */
  79399. enabled: boolean;
  79400. /**
  79401. * Defines a number that determines the order the extensions are applied.
  79402. */
  79403. order: number;
  79404. private _loader;
  79405. /** @hidden */
  79406. constructor(loader: GLTFLoader);
  79407. /** @hidden */
  79408. dispose(): void;
  79409. /** @hidden */
  79410. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79411. private _loadUnlitPropertiesAsync;
  79412. }
  79413. }
  79414. declare module BABYLON.GLTF2.Loader.Extensions {
  79415. /**
  79416. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  79417. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  79418. * !!! Experimental Extension Subject to Changes !!!
  79419. */
  79420. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  79421. /**
  79422. * The name of this extension.
  79423. */
  79424. readonly name: string;
  79425. /**
  79426. * Defines whether this extension is enabled.
  79427. */
  79428. enabled: boolean;
  79429. /**
  79430. * Defines a number that determines the order the extensions are applied.
  79431. */
  79432. order: number;
  79433. private _loader;
  79434. /** @hidden */
  79435. constructor(loader: GLTFLoader);
  79436. /** @hidden */
  79437. dispose(): void;
  79438. /** @hidden */
  79439. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79440. private _loadClearCoatPropertiesAsync;
  79441. }
  79442. }
  79443. declare module BABYLON.GLTF2.Loader.Extensions {
  79444. /**
  79445. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  79446. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  79447. * !!! Experimental Extension Subject to Changes !!!
  79448. */
  79449. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  79450. /**
  79451. * The name of this extension.
  79452. */
  79453. readonly name: string;
  79454. /**
  79455. * Defines whether this extension is enabled.
  79456. */
  79457. enabled: boolean;
  79458. /**
  79459. * Defines a number that determines the order the extensions are applied.
  79460. */
  79461. order: number;
  79462. private _loader;
  79463. /** @hidden */
  79464. constructor(loader: GLTFLoader);
  79465. /** @hidden */
  79466. dispose(): void;
  79467. /** @hidden */
  79468. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79469. private _loadSheenPropertiesAsync;
  79470. }
  79471. }
  79472. declare module BABYLON.GLTF2.Loader.Extensions {
  79473. /**
  79474. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  79475. * !!! Experimental Extension Subject to Changes !!!
  79476. */
  79477. export class KHR_materials_specular implements IGLTFLoaderExtension {
  79478. /**
  79479. * The name of this extension.
  79480. */
  79481. readonly name: string;
  79482. /**
  79483. * Defines whether this extension is enabled.
  79484. */
  79485. enabled: boolean;
  79486. /**
  79487. * Defines a number that determines the order the extensions are applied.
  79488. */
  79489. order: number;
  79490. private _loader;
  79491. /** @hidden */
  79492. constructor(loader: GLTFLoader);
  79493. /** @hidden */
  79494. dispose(): void;
  79495. /** @hidden */
  79496. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79497. private _loadSpecularPropertiesAsync;
  79498. }
  79499. }
  79500. declare module BABYLON.GLTF2.Loader.Extensions {
  79501. /**
  79502. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  79503. * !!! Experimental Extension Subject to Changes !!!
  79504. */
  79505. export class KHR_materials_ior implements IGLTFLoaderExtension {
  79506. /**
  79507. * Default ior Value from the spec.
  79508. */
  79509. private static readonly _DEFAULT_IOR;
  79510. /**
  79511. * The name of this extension.
  79512. */
  79513. readonly name: string;
  79514. /**
  79515. * Defines whether this extension is enabled.
  79516. */
  79517. enabled: boolean;
  79518. /**
  79519. * Defines a number that determines the order the extensions are applied.
  79520. */
  79521. order: number;
  79522. private _loader;
  79523. /** @hidden */
  79524. constructor(loader: GLTFLoader);
  79525. /** @hidden */
  79526. dispose(): void;
  79527. /** @hidden */
  79528. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79529. private _loadIorPropertiesAsync;
  79530. }
  79531. }
  79532. declare module BABYLON.GLTF2.Loader.Extensions {
  79533. /**
  79534. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  79535. */
  79536. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  79537. /**
  79538. * The name of this extension.
  79539. */
  79540. readonly name: string;
  79541. /**
  79542. * Defines whether this extension is enabled.
  79543. */
  79544. enabled: boolean;
  79545. /** @hidden */
  79546. constructor(loader: GLTFLoader);
  79547. /** @hidden */
  79548. dispose(): void;
  79549. }
  79550. }
  79551. declare module BABYLON.GLTF2.Loader.Extensions {
  79552. /**
  79553. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  79554. * !!! Experimental Extension Subject to Changes !!!
  79555. */
  79556. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  79557. /** The name of this extension. */
  79558. readonly name: string;
  79559. /** Defines whether this extension is enabled. */
  79560. enabled: boolean;
  79561. private _loader;
  79562. /** @hidden */
  79563. constructor(loader: GLTFLoader);
  79564. /** @hidden */
  79565. dispose(): void;
  79566. /** @hidden */
  79567. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79568. }
  79569. }
  79570. declare module BABYLON.GLTF2.Loader.Extensions {
  79571. /**
  79572. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  79573. */
  79574. export class KHR_texture_transform implements IGLTFLoaderExtension {
  79575. /**
  79576. * The name of this extension.
  79577. */
  79578. readonly name: string;
  79579. /**
  79580. * Defines whether this extension is enabled.
  79581. */
  79582. enabled: boolean;
  79583. private _loader;
  79584. /** @hidden */
  79585. constructor(loader: GLTFLoader);
  79586. /** @hidden */
  79587. dispose(): void;
  79588. /** @hidden */
  79589. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79590. }
  79591. }
  79592. declare module BABYLON.GLTF2.Loader.Extensions {
  79593. /**
  79594. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  79595. * !!! Experimental Extension Subject to Changes !!!
  79596. */
  79597. export class KHR_xmp implements IGLTFLoaderExtension {
  79598. /**
  79599. * The name of this extension.
  79600. */
  79601. readonly name: string;
  79602. /**
  79603. * Defines whether this extension is enabled.
  79604. */
  79605. enabled: boolean;
  79606. /**
  79607. * Defines a number that determines the order the extensions are applied.
  79608. */
  79609. order: number;
  79610. private _loader;
  79611. /** @hidden */
  79612. constructor(loader: GLTFLoader);
  79613. /** @hidden */
  79614. dispose(): void;
  79615. /**
  79616. * Called after the loader state changes to LOADING.
  79617. */
  79618. onLoading(): void;
  79619. }
  79620. }
  79621. declare module BABYLON.GLTF2.Loader.Extensions {
  79622. /**
  79623. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  79624. */
  79625. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  79626. /**
  79627. * The name of this extension.
  79628. */
  79629. readonly name: string;
  79630. /**
  79631. * Defines whether this extension is enabled.
  79632. */
  79633. enabled: boolean;
  79634. private _loader;
  79635. private _clips;
  79636. private _emitters;
  79637. /** @hidden */
  79638. constructor(loader: GLTFLoader);
  79639. /** @hidden */
  79640. dispose(): void;
  79641. /** @hidden */
  79642. onLoading(): void;
  79643. /** @hidden */
  79644. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79645. /** @hidden */
  79646. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79647. /** @hidden */
  79648. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79649. private _loadClipAsync;
  79650. private _loadEmitterAsync;
  79651. private _getEventAction;
  79652. private _loadAnimationEventAsync;
  79653. }
  79654. }
  79655. declare module BABYLON.GLTF2.Loader.Extensions {
  79656. /**
  79657. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  79658. */
  79659. export class MSFT_lod implements IGLTFLoaderExtension {
  79660. /**
  79661. * The name of this extension.
  79662. */
  79663. readonly name: string;
  79664. /**
  79665. * Defines whether this extension is enabled.
  79666. */
  79667. enabled: boolean;
  79668. /**
  79669. * Defines a number that determines the order the extensions are applied.
  79670. */
  79671. order: number;
  79672. /**
  79673. * Maximum number of LODs to load, starting from the lowest LOD.
  79674. */
  79675. maxLODsToLoad: number;
  79676. /**
  79677. * Observable raised when all node LODs of one level are loaded.
  79678. * The event data is the index of the loaded LOD starting from zero.
  79679. * Dispose the loader to cancel the loading of the next level of LODs.
  79680. */
  79681. onNodeLODsLoadedObservable: Observable<number>;
  79682. /**
  79683. * Observable raised when all material LODs of one level are loaded.
  79684. * The event data is the index of the loaded LOD starting from zero.
  79685. * Dispose the loader to cancel the loading of the next level of LODs.
  79686. */
  79687. onMaterialLODsLoadedObservable: Observable<number>;
  79688. private _loader;
  79689. private _nodeIndexLOD;
  79690. private _nodeSignalLODs;
  79691. private _nodePromiseLODs;
  79692. private _materialIndexLOD;
  79693. private _materialSignalLODs;
  79694. private _materialPromiseLODs;
  79695. private _indexLOD;
  79696. private _bufferLODs;
  79697. /** @hidden */
  79698. constructor(loader: GLTFLoader);
  79699. /** @hidden */
  79700. dispose(): void;
  79701. /** @hidden */
  79702. onReady(): void;
  79703. /** @hidden */
  79704. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79705. /** @hidden */
  79706. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79707. /** @hidden */
  79708. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79709. /** @hidden */
  79710. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79711. /** @hidden */
  79712. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79713. private _loadBufferLOD;
  79714. /**
  79715. * Gets an array of LOD properties from lowest to highest.
  79716. */
  79717. private _getLODs;
  79718. private _disposeTransformNode;
  79719. private _disposeMaterials;
  79720. }
  79721. }
  79722. declare module BABYLON.GLTF2.Loader.Extensions {
  79723. /** @hidden */
  79724. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  79725. readonly name: string;
  79726. enabled: boolean;
  79727. private _loader;
  79728. constructor(loader: GLTFLoader);
  79729. dispose(): void;
  79730. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79731. }
  79732. }
  79733. declare module BABYLON.GLTF2.Loader.Extensions {
  79734. /** @hidden */
  79735. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  79736. readonly name: string;
  79737. enabled: boolean;
  79738. private _loader;
  79739. constructor(loader: GLTFLoader);
  79740. dispose(): void;
  79741. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79742. }
  79743. }
  79744. declare module BABYLON.GLTF2.Loader.Extensions {
  79745. /**
  79746. * Store glTF extras (if present) in BJS objects' metadata
  79747. */
  79748. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  79749. /**
  79750. * The name of this extension.
  79751. */
  79752. readonly name: string;
  79753. /**
  79754. * Defines whether this extension is enabled.
  79755. */
  79756. enabled: boolean;
  79757. private _loader;
  79758. private _assignExtras;
  79759. /** @hidden */
  79760. constructor(loader: GLTFLoader);
  79761. /** @hidden */
  79762. dispose(): void;
  79763. /** @hidden */
  79764. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79765. /** @hidden */
  79766. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79767. /** @hidden */
  79768. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79769. }
  79770. }
  79771. declare module BABYLON {
  79772. /**
  79773. * Class reading and parsing the MTL file bundled with the obj file.
  79774. */
  79775. export class MTLFileLoader {
  79776. /**
  79777. * Invert Y-Axis of referenced textures on load
  79778. */
  79779. static INVERT_TEXTURE_Y: boolean;
  79780. /**
  79781. * All material loaded from the mtl will be set here
  79782. */
  79783. materials: StandardMaterial[];
  79784. /**
  79785. * This function will read the mtl file and create each material described inside
  79786. * This function could be improve by adding :
  79787. * -some component missing (Ni, Tf...)
  79788. * -including the specific options available
  79789. *
  79790. * @param scene defines the scene the material will be created in
  79791. * @param data defines the mtl data to parse
  79792. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  79793. * @param forAssetContainer defines if the material should be registered in the scene
  79794. */
  79795. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  79796. /**
  79797. * Gets the texture for the material.
  79798. *
  79799. * If the material is imported from input file,
  79800. * We sanitize the url to ensure it takes the textre from aside the material.
  79801. *
  79802. * @param rootUrl The root url to load from
  79803. * @param value The value stored in the mtl
  79804. * @return The Texture
  79805. */
  79806. private static _getTexture;
  79807. }
  79808. }
  79809. declare module BABYLON {
  79810. /**
  79811. * Options for loading OBJ/MTL files
  79812. */
  79813. type MeshLoadOptions = {
  79814. /**
  79815. * Defines if UVs are optimized by default during load.
  79816. */
  79817. OptimizeWithUV: boolean;
  79818. /**
  79819. * Defines custom scaling of UV coordinates of loaded meshes.
  79820. */
  79821. UVScaling: Vector2;
  79822. /**
  79823. * Invert model on y-axis (does a model scaling inversion)
  79824. */
  79825. InvertY: boolean;
  79826. /**
  79827. * Invert Y-Axis of referenced textures on load
  79828. */
  79829. InvertTextureY: boolean;
  79830. /**
  79831. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  79832. */
  79833. ImportVertexColors: boolean;
  79834. /**
  79835. * Compute the normals for the model, even if normals are present in the file.
  79836. */
  79837. ComputeNormals: boolean;
  79838. /**
  79839. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  79840. */
  79841. SkipMaterials: boolean;
  79842. /**
  79843. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  79844. */
  79845. MaterialLoadingFailsSilently: boolean;
  79846. };
  79847. /**
  79848. * OBJ file type loader.
  79849. * This is a babylon scene loader plugin.
  79850. */
  79851. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79852. /**
  79853. * Defines if UVs are optimized by default during load.
  79854. */
  79855. static OPTIMIZE_WITH_UV: boolean;
  79856. /**
  79857. * Invert model on y-axis (does a model scaling inversion)
  79858. */
  79859. static INVERT_Y: boolean;
  79860. /**
  79861. * Invert Y-Axis of referenced textures on load
  79862. */
  79863. static get INVERT_TEXTURE_Y(): boolean;
  79864. static set INVERT_TEXTURE_Y(value: boolean);
  79865. /**
  79866. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  79867. */
  79868. static IMPORT_VERTEX_COLORS: boolean;
  79869. /**
  79870. * Compute the normals for the model, even if normals are present in the file.
  79871. */
  79872. static COMPUTE_NORMALS: boolean;
  79873. /**
  79874. * Defines custom scaling of UV coordinates of loaded meshes.
  79875. */
  79876. static UV_SCALING: Vector2;
  79877. /**
  79878. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  79879. */
  79880. static SKIP_MATERIALS: boolean;
  79881. /**
  79882. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  79883. *
  79884. * Defaults to true for backwards compatibility.
  79885. */
  79886. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  79887. /**
  79888. * Defines the name of the plugin.
  79889. */
  79890. name: string;
  79891. /**
  79892. * Defines the extension the plugin is able to load.
  79893. */
  79894. extensions: string;
  79895. /** @hidden */
  79896. obj: RegExp;
  79897. /** @hidden */
  79898. group: RegExp;
  79899. /** @hidden */
  79900. mtllib: RegExp;
  79901. /** @hidden */
  79902. usemtl: RegExp;
  79903. /** @hidden */
  79904. smooth: RegExp;
  79905. /** @hidden */
  79906. vertexPattern: RegExp;
  79907. /** @hidden */
  79908. normalPattern: RegExp;
  79909. /** @hidden */
  79910. uvPattern: RegExp;
  79911. /** @hidden */
  79912. facePattern1: RegExp;
  79913. /** @hidden */
  79914. facePattern2: RegExp;
  79915. /** @hidden */
  79916. facePattern3: RegExp;
  79917. /** @hidden */
  79918. facePattern4: RegExp;
  79919. /** @hidden */
  79920. facePattern5: RegExp;
  79921. private _forAssetContainer;
  79922. private _meshLoadOptions;
  79923. /**
  79924. * Creates loader for .OBJ files
  79925. *
  79926. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  79927. */
  79928. constructor(meshLoadOptions?: MeshLoadOptions);
  79929. private static get currentMeshLoadOptions();
  79930. /**
  79931. * Calls synchronously the MTL file attached to this obj.
  79932. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  79933. * Without this function materials are not displayed in the first frame (but displayed after).
  79934. * In consequence it is impossible to get material information in your HTML file
  79935. *
  79936. * @param url The URL of the MTL file
  79937. * @param rootUrl
  79938. * @param onSuccess Callback function to be called when the MTL file is loaded
  79939. * @private
  79940. */
  79941. private _loadMTL;
  79942. /**
  79943. * Instantiates a OBJ file loader plugin.
  79944. * @returns the created plugin
  79945. */
  79946. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  79947. /**
  79948. * If the data string can be loaded directly.
  79949. *
  79950. * @param data string containing the file data
  79951. * @returns if the data can be loaded directly
  79952. */
  79953. canDirectLoad(data: string): boolean;
  79954. /**
  79955. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  79956. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79957. * @param scene the scene the meshes should be added to
  79958. * @param data the OBJ data to load
  79959. * @param rootUrl root url to load from
  79960. * @param onProgress event that fires when loading progress has occured
  79961. * @param fileName Defines the name of the file to load
  79962. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79963. */
  79964. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79965. meshes: AbstractMesh[];
  79966. particleSystems: IParticleSystem[];
  79967. skeletons: Skeleton[];
  79968. animationGroups: AnimationGroup[];
  79969. }>;
  79970. /**
  79971. * Imports all objects from the loaded OBJ data and adds them to the scene
  79972. * @param scene the scene the objects should be added to
  79973. * @param data the OBJ data to load
  79974. * @param rootUrl root url to load from
  79975. * @param onProgress event that fires when loading progress has occured
  79976. * @param fileName Defines the name of the file to load
  79977. * @returns a promise which completes when objects have been loaded to the scene
  79978. */
  79979. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79980. /**
  79981. * Load into an asset container.
  79982. * @param scene The scene to load into
  79983. * @param data The data to import
  79984. * @param rootUrl The root url for scene and resources
  79985. * @param onProgress The callback when the load progresses
  79986. * @param fileName Defines the name of the file to load
  79987. * @returns The loaded asset container
  79988. */
  79989. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79990. /**
  79991. * Read the OBJ file and create an Array of meshes.
  79992. * Each mesh contains all information given by the OBJ and the MTL file.
  79993. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  79994. *
  79995. * @param meshesNames
  79996. * @param scene Scene The scene where are displayed the data
  79997. * @param data String The content of the obj file
  79998. * @param rootUrl String The path to the folder
  79999. * @returns Array<AbstractMesh>
  80000. * @private
  80001. */
  80002. private _parseSolid;
  80003. }
  80004. }
  80005. declare module BABYLON {
  80006. /**
  80007. * STL file type loader.
  80008. * This is a babylon scene loader plugin.
  80009. */
  80010. export class STLFileLoader implements ISceneLoaderPlugin {
  80011. /** @hidden */
  80012. solidPattern: RegExp;
  80013. /** @hidden */
  80014. facetsPattern: RegExp;
  80015. /** @hidden */
  80016. normalPattern: RegExp;
  80017. /** @hidden */
  80018. vertexPattern: RegExp;
  80019. /**
  80020. * Defines the name of the plugin.
  80021. */
  80022. name: string;
  80023. /**
  80024. * Defines the extensions the stl loader is able to load.
  80025. * force data to come in as an ArrayBuffer
  80026. * we'll convert to string if it looks like it's an ASCII .stl
  80027. */
  80028. extensions: ISceneLoaderPluginExtensions;
  80029. /**
  80030. * Import meshes into a scene.
  80031. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  80032. * @param scene The scene to import into
  80033. * @param data The data to import
  80034. * @param rootUrl The root url for scene and resources
  80035. * @param meshes The meshes array to import into
  80036. * @param particleSystems The particle systems array to import into
  80037. * @param skeletons The skeletons array to import into
  80038. * @param onError The callback when import fails
  80039. * @returns True if successful or false otherwise
  80040. */
  80041. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80042. /**
  80043. * Load into a scene.
  80044. * @param scene The scene to load into
  80045. * @param data The data to import
  80046. * @param rootUrl The root url for scene and resources
  80047. * @param onError The callback when import fails
  80048. * @returns true if successful or false otherwise
  80049. */
  80050. load(scene: Scene, data: any, rootUrl: string): boolean;
  80051. /**
  80052. * Load into an asset container.
  80053. * @param scene The scene to load into
  80054. * @param data The data to import
  80055. * @param rootUrl The root url for scene and resources
  80056. * @param onError The callback when import fails
  80057. * @returns The loaded asset container
  80058. */
  80059. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  80060. private _isBinary;
  80061. private _parseBinary;
  80062. private _parseASCII;
  80063. }
  80064. }
  80065. declare module BABYLON {
  80066. /**
  80067. * Class for generating OBJ data from a Babylon scene.
  80068. */
  80069. export class OBJExport {
  80070. /**
  80071. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80072. * @param mesh defines the list of meshes to serialize
  80073. * @param materials defines if materials should be exported
  80074. * @param matlibname defines the name of the associated mtl file
  80075. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80076. * @returns the OBJ content
  80077. */
  80078. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80079. /**
  80080. * Exports the material(s) of a mesh in .MTL file format (text)
  80081. * @param mesh defines the mesh to extract the material from
  80082. * @returns the mtl content
  80083. */
  80084. static MTL(mesh: Mesh): string;
  80085. }
  80086. }
  80087. declare module BABYLON {
  80088. /** @hidden */
  80089. export var __IGLTFExporterExtension: number;
  80090. /**
  80091. * Interface for extending the exporter
  80092. * @hidden
  80093. */
  80094. export interface IGLTFExporterExtension {
  80095. /**
  80096. * The name of this extension
  80097. */
  80098. readonly name: string;
  80099. /**
  80100. * Defines whether this extension is enabled
  80101. */
  80102. enabled: boolean;
  80103. /**
  80104. * Defines whether this extension is required
  80105. */
  80106. required: boolean;
  80107. }
  80108. }
  80109. declare module BABYLON.GLTF2.Exporter {
  80110. /** @hidden */
  80111. export var __IGLTFExporterExtensionV2: number;
  80112. /**
  80113. * Interface for a glTF exporter extension
  80114. * @hidden
  80115. */
  80116. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80117. /**
  80118. * Define this method to modify the default behavior before exporting a texture
  80119. * @param context The context when loading the asset
  80120. * @param babylonTexture The Babylon.js texture
  80121. * @param mimeType The mime-type of the generated image
  80122. * @returns A promise that resolves with the exported texture
  80123. */
  80124. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80125. /**
  80126. * Define this method to get notified when a texture info is created
  80127. * @param context The context when loading the asset
  80128. * @param textureInfo The glTF texture info
  80129. * @param babylonTexture The Babylon.js texture
  80130. */
  80131. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80132. /**
  80133. * Define this method to modify the default behavior when exporting texture info
  80134. * @param context The context when loading the asset
  80135. * @param meshPrimitive glTF mesh primitive
  80136. * @param babylonSubMesh Babylon submesh
  80137. * @param binaryWriter glTF serializer binary writer instance
  80138. * @returns nullable IMeshPrimitive promise
  80139. */
  80140. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80141. /**
  80142. * Define this method to modify the default behavior when exporting a node
  80143. * @param context The context when exporting the node
  80144. * @param node glTF node
  80145. * @param babylonNode BabylonJS node
  80146. * @returns nullable INode promise
  80147. */
  80148. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80149. [key: number]: number;
  80150. }): Promise<Nullable<INode>>;
  80151. /**
  80152. * Define this method to modify the default behavior when exporting a material
  80153. * @param material glTF material
  80154. * @param babylonMaterial BabylonJS material
  80155. * @returns nullable IMaterial promise
  80156. */
  80157. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80158. /**
  80159. * Define this method to return additional textures to export from a material
  80160. * @param material glTF material
  80161. * @param babylonMaterial BabylonJS material
  80162. * @returns List of textures
  80163. */
  80164. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80165. /** Gets a boolean indicating that this extension was used */
  80166. wasUsed: boolean;
  80167. /** Gets a boolean indicating that this extension is required for the file to work */
  80168. required: boolean;
  80169. /**
  80170. * Called after the exporter state changes to EXPORTING
  80171. */
  80172. onExporting?(): void;
  80173. }
  80174. }
  80175. declare module BABYLON.GLTF2.Exporter {
  80176. /**
  80177. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80178. * @hidden
  80179. */
  80180. export class _GLTFMaterialExporter {
  80181. /**
  80182. * Represents the dielectric specular values for R, G and B
  80183. */
  80184. private static readonly _DielectricSpecular;
  80185. /**
  80186. * Allows the maximum specular power to be defined for material calculations
  80187. */
  80188. private static readonly _MaxSpecularPower;
  80189. /**
  80190. * Mapping to store textures
  80191. */
  80192. private _textureMap;
  80193. /**
  80194. * Numeric tolerance value
  80195. */
  80196. private static readonly _Epsilon;
  80197. /**
  80198. * Reference to the glTF Exporter
  80199. */
  80200. private _exporter;
  80201. constructor(exporter: _Exporter);
  80202. /**
  80203. * Specifies if two colors are approximately equal in value
  80204. * @param color1 first color to compare to
  80205. * @param color2 second color to compare to
  80206. * @param epsilon threshold value
  80207. */
  80208. private static FuzzyEquals;
  80209. /**
  80210. * Gets the materials from a Babylon scene and converts them to glTF materials
  80211. * @param scene babylonjs scene
  80212. * @param mimeType texture mime type
  80213. * @param images array of images
  80214. * @param textures array of textures
  80215. * @param materials array of materials
  80216. * @param imageData mapping of texture names to base64 textures
  80217. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80218. */
  80219. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80220. /**
  80221. * Makes a copy of the glTF material without the texture parameters
  80222. * @param originalMaterial original glTF material
  80223. * @returns glTF material without texture parameters
  80224. */
  80225. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80226. /**
  80227. * Specifies if the material has any texture parameters present
  80228. * @param material glTF Material
  80229. * @returns boolean specifying if texture parameters are present
  80230. */
  80231. _hasTexturesPresent(material: IMaterial): boolean;
  80232. /**
  80233. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80234. * @param babylonStandardMaterial
  80235. * @returns glTF Metallic Roughness Material representation
  80236. */
  80237. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80238. /**
  80239. * Computes the metallic factor
  80240. * @param diffuse diffused value
  80241. * @param specular specular value
  80242. * @param oneMinusSpecularStrength one minus the specular strength
  80243. * @returns metallic value
  80244. */
  80245. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80246. /**
  80247. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80248. * @param glTFMaterial glTF material
  80249. * @param babylonMaterial Babylon material
  80250. */
  80251. private static _SetAlphaMode;
  80252. /**
  80253. * Converts a Babylon Standard Material to a glTF Material
  80254. * @param babylonStandardMaterial BJS Standard Material
  80255. * @param mimeType mime type to use for the textures
  80256. * @param images array of glTF image interfaces
  80257. * @param textures array of glTF texture interfaces
  80258. * @param materials array of glTF material interfaces
  80259. * @param imageData map of image file name to data
  80260. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80261. */
  80262. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80263. private _finishMaterial;
  80264. /**
  80265. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80266. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  80267. * @param mimeType mime type to use for the textures
  80268. * @param images array of glTF image interfaces
  80269. * @param textures array of glTF texture interfaces
  80270. * @param materials array of glTF material interfaces
  80271. * @param imageData map of image file name to data
  80272. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80273. */
  80274. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80275. /**
  80276. * Converts an image typed array buffer to a base64 image
  80277. * @param buffer typed array buffer
  80278. * @param width width of the image
  80279. * @param height height of the image
  80280. * @param mimeType mimetype of the image
  80281. * @returns base64 image string
  80282. */
  80283. private _createBase64FromCanvasAsync;
  80284. /**
  80285. * Generates a white texture based on the specified width and height
  80286. * @param width width of the texture in pixels
  80287. * @param height height of the texture in pixels
  80288. * @param scene babylonjs scene
  80289. * @returns white texture
  80290. */
  80291. private _createWhiteTexture;
  80292. /**
  80293. * 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
  80294. * @param texture1 first texture to resize
  80295. * @param texture2 second texture to resize
  80296. * @param scene babylonjs scene
  80297. * @returns resized textures or null
  80298. */
  80299. private _resizeTexturesToSameDimensions;
  80300. /**
  80301. * Converts an array of pixels to a Float32Array
  80302. * Throws an error if the pixel format is not supported
  80303. * @param pixels - array buffer containing pixel values
  80304. * @returns Float32 of pixels
  80305. */
  80306. private _convertPixelArrayToFloat32;
  80307. /**
  80308. * Convert Specular Glossiness Textures to Metallic Roughness
  80309. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  80310. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  80311. * @param diffuseTexture texture used to store diffuse information
  80312. * @param specularGlossinessTexture texture used to store specular and glossiness information
  80313. * @param factors specular glossiness material factors
  80314. * @param mimeType the mime type to use for the texture
  80315. * @returns pbr metallic roughness interface or null
  80316. */
  80317. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  80318. /**
  80319. * Converts specular glossiness material properties to metallic roughness
  80320. * @param specularGlossiness interface with specular glossiness material properties
  80321. * @returns interface with metallic roughness material properties
  80322. */
  80323. private _convertSpecularGlossinessToMetallicRoughness;
  80324. /**
  80325. * Calculates the surface reflectance, independent of lighting conditions
  80326. * @param color Color source to calculate brightness from
  80327. * @returns number representing the perceived brightness, or zero if color is undefined
  80328. */
  80329. private _getPerceivedBrightness;
  80330. /**
  80331. * Returns the maximum color component value
  80332. * @param color
  80333. * @returns maximum color component value, or zero if color is null or undefined
  80334. */
  80335. private _getMaxComponent;
  80336. /**
  80337. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  80338. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80339. * @param mimeType mime type to use for the textures
  80340. * @param images array of glTF image interfaces
  80341. * @param textures array of glTF texture interfaces
  80342. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80343. * @param imageData map of image file name to data
  80344. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80345. * @returns glTF PBR Metallic Roughness factors
  80346. */
  80347. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  80348. private _getGLTFTextureSampler;
  80349. private _getGLTFTextureWrapMode;
  80350. private _getGLTFTextureWrapModesSampler;
  80351. /**
  80352. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  80353. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80354. * @param mimeType mime type to use for the textures
  80355. * @param images array of glTF image interfaces
  80356. * @param textures array of glTF texture interfaces
  80357. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80358. * @param imageData map of image file name to data
  80359. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80360. * @returns glTF PBR Metallic Roughness factors
  80361. */
  80362. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  80363. /**
  80364. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80365. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80366. * @param mimeType mime type to use for the textures
  80367. * @param images array of glTF image interfaces
  80368. * @param textures array of glTF texture interfaces
  80369. * @param materials array of glTF material interfaces
  80370. * @param imageData map of image file name to data
  80371. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80372. */
  80373. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80374. private setMetallicRoughnessPbrMaterial;
  80375. private getPixelsFromTexture;
  80376. /**
  80377. * Extracts a texture from a Babylon texture into file data and glTF data
  80378. * @param babylonTexture Babylon texture to extract
  80379. * @param mimeType Mime Type of the babylonTexture
  80380. * @return glTF texture info, or null if the texture format is not supported
  80381. */
  80382. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80383. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80384. /**
  80385. * Builds a texture from base64 string
  80386. * @param base64Texture base64 texture string
  80387. * @param baseTextureName Name to use for the texture
  80388. * @param mimeType image mime type for the texture
  80389. * @param images array of images
  80390. * @param textures array of textures
  80391. * @param imageData map of image data
  80392. * @returns glTF texture info, or null if the texture format is not supported
  80393. */
  80394. private _getTextureInfoFromBase64;
  80395. }
  80396. }
  80397. declare module BABYLON {
  80398. /**
  80399. * Class for holding and downloading glTF file data
  80400. */
  80401. export class GLTFData {
  80402. /**
  80403. * Object which contains the file name as the key and its data as the value
  80404. */
  80405. glTFFiles: {
  80406. [fileName: string]: string | Blob;
  80407. };
  80408. /**
  80409. * Initializes the glTF file object
  80410. */
  80411. constructor();
  80412. /**
  80413. * Downloads the glTF data as files based on their names and data
  80414. */
  80415. downloadFiles(): void;
  80416. }
  80417. }
  80418. declare module BABYLON {
  80419. /**
  80420. * Holds a collection of exporter options and parameters
  80421. */
  80422. export interface IExportOptions {
  80423. /**
  80424. * Function which indicates whether a babylon node should be exported or not
  80425. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  80426. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  80427. */
  80428. shouldExportNode?(node: Node): boolean;
  80429. /**
  80430. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  80431. * @param metadata source metadata to read from
  80432. * @returns the data to store to glTF node extras
  80433. */
  80434. metadataSelector?(metadata: any): any;
  80435. /**
  80436. * The sample rate to bake animation curves
  80437. */
  80438. animationSampleRate?: number;
  80439. /**
  80440. * Begin serialization without waiting for the scene to be ready
  80441. */
  80442. exportWithoutWaitingForScene?: boolean;
  80443. /**
  80444. * Indicates if coordinate system swapping root nodes should be included in export
  80445. */
  80446. includeCoordinateSystemConversionNodes?: boolean;
  80447. }
  80448. /**
  80449. * Class for generating glTF data from a Babylon scene.
  80450. */
  80451. export class GLTF2Export {
  80452. /**
  80453. * Exports the geometry of the scene to .gltf file format asynchronously
  80454. * @param scene Babylon scene with scene hierarchy information
  80455. * @param filePrefix File prefix to use when generating the glTF file
  80456. * @param options Exporter options
  80457. * @returns Returns an object with a .gltf file and associates texture names
  80458. * as keys and their data and paths as values
  80459. */
  80460. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80461. private static _PreExportAsync;
  80462. private static _PostExportAsync;
  80463. /**
  80464. * Exports the geometry of the scene to .glb file format asychronously
  80465. * @param scene Babylon scene with scene hierarchy information
  80466. * @param filePrefix File prefix to use when generating glb file
  80467. * @param options Exporter options
  80468. * @returns Returns an object with a .glb filename as key and data as value
  80469. */
  80470. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80471. }
  80472. }
  80473. declare module BABYLON.GLTF2.Exporter {
  80474. /**
  80475. * @hidden
  80476. */
  80477. export class _GLTFUtilities {
  80478. /**
  80479. * Creates a buffer view based on the supplied arguments
  80480. * @param bufferIndex index value of the specified buffer
  80481. * @param byteOffset byte offset value
  80482. * @param byteLength byte length of the bufferView
  80483. * @param byteStride byte distance between conequential elements
  80484. * @param name name of the buffer view
  80485. * @returns bufferView for glTF
  80486. */
  80487. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  80488. /**
  80489. * Creates an accessor based on the supplied arguments
  80490. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  80491. * @param name The name of the accessor
  80492. * @param type The type of the accessor
  80493. * @param componentType The datatype of components in the attribute
  80494. * @param count The number of attributes referenced by this accessor
  80495. * @param byteOffset The offset relative to the start of the bufferView in bytes
  80496. * @param min Minimum value of each component in this attribute
  80497. * @param max Maximum value of each component in this attribute
  80498. * @returns accessor for glTF
  80499. */
  80500. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  80501. /**
  80502. * Calculates the minimum and maximum values of an array of position floats
  80503. * @param positions Positions array of a mesh
  80504. * @param vertexStart Starting vertex offset to calculate min and max values
  80505. * @param vertexCount Number of vertices to check for min and max values
  80506. * @returns min number array and max number array
  80507. */
  80508. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  80509. min: number[];
  80510. max: number[];
  80511. };
  80512. /**
  80513. * Converts a new right-handed Vector3
  80514. * @param vector vector3 array
  80515. * @returns right-handed Vector3
  80516. */
  80517. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  80518. /**
  80519. * Converts a Vector3 to right-handed
  80520. * @param vector Vector3 to convert to right-handed
  80521. */
  80522. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  80523. /**
  80524. * Converts a three element number array to right-handed
  80525. * @param vector number array to convert to right-handed
  80526. */
  80527. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  80528. /**
  80529. * Converts a new right-handed Vector3
  80530. * @param vector vector3 array
  80531. * @returns right-handed Vector3
  80532. */
  80533. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  80534. /**
  80535. * Converts a Vector3 to right-handed
  80536. * @param vector Vector3 to convert to right-handed
  80537. */
  80538. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  80539. /**
  80540. * Converts a three element number array to right-handed
  80541. * @param vector number array to convert to right-handed
  80542. */
  80543. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  80544. /**
  80545. * Converts a Vector4 to right-handed
  80546. * @param vector Vector4 to convert to right-handed
  80547. */
  80548. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  80549. /**
  80550. * Converts a Vector4 to right-handed
  80551. * @param vector Vector4 to convert to right-handed
  80552. */
  80553. static _GetRightHandedArray4FromRef(vector: number[]): void;
  80554. /**
  80555. * Converts a Quaternion to right-handed
  80556. * @param quaternion Source quaternion to convert to right-handed
  80557. */
  80558. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  80559. /**
  80560. * Converts a Quaternion to right-handed
  80561. * @param quaternion Source quaternion to convert to right-handed
  80562. */
  80563. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  80564. static _NormalizeTangentFromRef(tangent: Vector4): void;
  80565. }
  80566. }
  80567. declare module BABYLON.GLTF2.Exporter {
  80568. /**
  80569. * Converts Babylon Scene into glTF 2.0.
  80570. * @hidden
  80571. */
  80572. export class _Exporter {
  80573. /**
  80574. * Stores the glTF to export
  80575. */
  80576. _glTF: IGLTF;
  80577. /**
  80578. * Stores all generated buffer views, which represents views into the main glTF buffer data
  80579. */
  80580. _bufferViews: IBufferView[];
  80581. /**
  80582. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  80583. */
  80584. _accessors: IAccessor[];
  80585. /**
  80586. * Stores all the generated nodes, which contains transform and/or mesh information per node
  80587. */
  80588. _nodes: INode[];
  80589. /**
  80590. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  80591. */
  80592. private _scenes;
  80593. /**
  80594. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  80595. */
  80596. private _meshes;
  80597. /**
  80598. * Stores all the generated material information, which represents the appearance of each primitive
  80599. */
  80600. _materials: IMaterial[];
  80601. _materialMap: {
  80602. [materialID: number]: number;
  80603. };
  80604. /**
  80605. * Stores all the generated texture information, which is referenced by glTF materials
  80606. */
  80607. _textures: ITexture[];
  80608. /**
  80609. * Stores all the generated image information, which is referenced by glTF textures
  80610. */
  80611. _images: IImage[];
  80612. /**
  80613. * Stores all the texture samplers
  80614. */
  80615. _samplers: ISampler[];
  80616. /**
  80617. * Stores all the generated animation samplers, which is referenced by glTF animations
  80618. */
  80619. /**
  80620. * Stores the animations for glTF models
  80621. */
  80622. private _animations;
  80623. /**
  80624. * Stores the total amount of bytes stored in the glTF buffer
  80625. */
  80626. private _totalByteLength;
  80627. /**
  80628. * Stores a reference to the Babylon scene containing the source geometry and material information
  80629. */
  80630. _babylonScene: Scene;
  80631. /**
  80632. * Stores a map of the image data, where the key is the file name and the value
  80633. * is the image data
  80634. */
  80635. _imageData: {
  80636. [fileName: string]: {
  80637. data: Uint8Array;
  80638. mimeType: ImageMimeType;
  80639. };
  80640. };
  80641. /**
  80642. * Stores a map of the unique id of a node to its index in the node array
  80643. */
  80644. _nodeMap: {
  80645. [key: number]: number;
  80646. };
  80647. /**
  80648. * Specifies if the source Babylon scene was left handed, and needed conversion.
  80649. */
  80650. _convertToRightHandedSystem: boolean;
  80651. /**
  80652. * Specifies if a Babylon node should be converted to right-handed on export
  80653. */
  80654. _convertToRightHandedSystemMap: {
  80655. [nodeId: number]: boolean;
  80656. };
  80657. _includeCoordinateSystemConversionNodes: boolean;
  80658. /**
  80659. * Baked animation sample rate
  80660. */
  80661. private _animationSampleRate;
  80662. private _options;
  80663. private _localEngine;
  80664. _glTFMaterialExporter: _GLTFMaterialExporter;
  80665. private _extensions;
  80666. private static _ExtensionNames;
  80667. private static _ExtensionFactories;
  80668. private _applyExtension;
  80669. private _applyExtensions;
  80670. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  80671. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  80672. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80673. [key: number]: number;
  80674. }): Promise<Nullable<INode>>;
  80675. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  80676. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  80677. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80678. private _forEachExtensions;
  80679. private _extensionsOnExporting;
  80680. /**
  80681. * Load glTF serializer extensions
  80682. */
  80683. private _loadExtensions;
  80684. /**
  80685. * Creates a glTF Exporter instance, which can accept optional exporter options
  80686. * @param babylonScene Babylon scene object
  80687. * @param options Options to modify the behavior of the exporter
  80688. */
  80689. constructor(babylonScene: Scene, options?: IExportOptions);
  80690. dispose(): void;
  80691. /**
  80692. * Registers a glTF exporter extension
  80693. * @param name Name of the extension to export
  80694. * @param factory The factory function that creates the exporter extension
  80695. */
  80696. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  80697. /**
  80698. * Un-registers an exporter extension
  80699. * @param name The name fo the exporter extension
  80700. * @returns A boolean indicating whether the extension has been un-registered
  80701. */
  80702. static UnregisterExtension(name: string): boolean;
  80703. /**
  80704. * Lazy load a local engine
  80705. */
  80706. _getLocalEngine(): Engine;
  80707. private reorderIndicesBasedOnPrimitiveMode;
  80708. /**
  80709. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  80710. * clock-wise during export to glTF
  80711. * @param submesh BabylonJS submesh
  80712. * @param primitiveMode Primitive mode of the mesh
  80713. * @param sideOrientation the winding order of the submesh
  80714. * @param vertexBufferKind The type of vertex attribute
  80715. * @param meshAttributeArray The vertex attribute data
  80716. * @param byteOffset The offset to the binary data
  80717. * @param binaryWriter The binary data for the glTF file
  80718. * @param convertToRightHandedSystem Converts the values to right-handed
  80719. */
  80720. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  80721. /**
  80722. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  80723. * clock-wise during export to glTF
  80724. * @param submesh BabylonJS submesh
  80725. * @param primitiveMode Primitive mode of the mesh
  80726. * @param sideOrientation the winding order of the submesh
  80727. * @param vertexBufferKind The type of vertex attribute
  80728. * @param meshAttributeArray The vertex attribute data
  80729. * @param byteOffset The offset to the binary data
  80730. * @param binaryWriter The binary data for the glTF file
  80731. * @param convertToRightHandedSystem Converts the values to right-handed
  80732. */
  80733. private reorderTriangleFillMode;
  80734. /**
  80735. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  80736. * clock-wise during export to glTF
  80737. * @param submesh BabylonJS submesh
  80738. * @param primitiveMode Primitive mode of the mesh
  80739. * @param sideOrientation the winding order of the submesh
  80740. * @param vertexBufferKind The type of vertex attribute
  80741. * @param meshAttributeArray The vertex attribute data
  80742. * @param byteOffset The offset to the binary data
  80743. * @param binaryWriter The binary data for the glTF file
  80744. * @param convertToRightHandedSystem Converts the values to right-handed
  80745. */
  80746. private reorderTriangleStripDrawMode;
  80747. /**
  80748. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  80749. * clock-wise during export to glTF
  80750. * @param submesh BabylonJS submesh
  80751. * @param primitiveMode Primitive mode of the mesh
  80752. * @param sideOrientation the winding order of the submesh
  80753. * @param vertexBufferKind The type of vertex attribute
  80754. * @param meshAttributeArray The vertex attribute data
  80755. * @param byteOffset The offset to the binary data
  80756. * @param binaryWriter The binary data for the glTF file
  80757. * @param convertToRightHandedSystem Converts the values to right-handed
  80758. */
  80759. private reorderTriangleFanMode;
  80760. /**
  80761. * Writes the vertex attribute data to binary
  80762. * @param vertices The vertices to write to the binary writer
  80763. * @param byteOffset The offset into the binary writer to overwrite binary data
  80764. * @param vertexAttributeKind The vertex attribute type
  80765. * @param meshAttributeArray The vertex attribute data
  80766. * @param binaryWriter The writer containing the binary data
  80767. * @param convertToRightHandedSystem Converts the values to right-handed
  80768. */
  80769. private writeVertexAttributeData;
  80770. /**
  80771. * Writes mesh attribute data to a data buffer
  80772. * Returns the bytelength of the data
  80773. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  80774. * @param meshAttributeArray Array containing the attribute data
  80775. * @param binaryWriter The buffer to write the binary data to
  80776. * @param indices Used to specify the order of the vertex data
  80777. * @param convertToRightHandedSystem Converts the values to right-handed
  80778. */
  80779. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  80780. /**
  80781. * Generates glTF json data
  80782. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  80783. * @param glTFPrefix Text to use when prefixing a glTF file
  80784. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  80785. * @returns json data as string
  80786. */
  80787. private generateJSON;
  80788. /**
  80789. * Generates data for .gltf and .bin files based on the glTF prefix string
  80790. * @param glTFPrefix Text to use when prefixing a glTF file
  80791. * @param dispose Dispose the exporter
  80792. * @returns GLTFData with glTF file data
  80793. */
  80794. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80795. /**
  80796. * Creates a binary buffer for glTF
  80797. * @returns array buffer for binary data
  80798. */
  80799. private _generateBinaryAsync;
  80800. /**
  80801. * Pads the number to a multiple of 4
  80802. * @param num number to pad
  80803. * @returns padded number
  80804. */
  80805. private _getPadding;
  80806. /**
  80807. * @hidden
  80808. */
  80809. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80810. /**
  80811. * Sets the TRS for each node
  80812. * @param node glTF Node for storing the transformation data
  80813. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  80814. * @param convertToRightHandedSystem Converts the values to right-handed
  80815. */
  80816. private setNodeTransformation;
  80817. private getVertexBufferFromMesh;
  80818. /**
  80819. * Creates a bufferview based on the vertices type for the Babylon mesh
  80820. * @param kind Indicates the type of vertices data
  80821. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  80822. * @param binaryWriter The buffer to write the bufferview data to
  80823. * @param convertToRightHandedSystem Converts the values to right-handed
  80824. */
  80825. private createBufferViewKind;
  80826. /**
  80827. * The primitive mode of the Babylon mesh
  80828. * @param babylonMesh The BabylonJS mesh
  80829. */
  80830. private getMeshPrimitiveMode;
  80831. /**
  80832. * Sets the primitive mode of the glTF mesh primitive
  80833. * @param meshPrimitive glTF mesh primitive
  80834. * @param primitiveMode The primitive mode
  80835. */
  80836. private setPrimitiveMode;
  80837. /**
  80838. * Sets the vertex attribute accessor based of the glTF mesh primitive
  80839. * @param meshPrimitive glTF mesh primitive
  80840. * @param attributeKind vertex attribute
  80841. * @returns boolean specifying if uv coordinates are present
  80842. */
  80843. private setAttributeKind;
  80844. /**
  80845. * Sets data for the primitive attributes of each submesh
  80846. * @param mesh glTF Mesh object to store the primitive attribute information
  80847. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  80848. * @param binaryWriter Buffer to write the attribute data to
  80849. * @param convertToRightHandedSystem Converts the values to right-handed
  80850. */
  80851. private setPrimitiveAttributesAsync;
  80852. /**
  80853. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  80854. * @param node The node to check
  80855. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  80856. */
  80857. private isBabylonCoordinateSystemConvertingNode;
  80858. /**
  80859. * Creates a glTF scene based on the array of meshes
  80860. * Returns the the total byte offset
  80861. * @param babylonScene Babylon scene to get the mesh data from
  80862. * @param binaryWriter Buffer to write binary data to
  80863. */
  80864. private createSceneAsync;
  80865. /**
  80866. * Creates a mapping of Node unique id to node index and handles animations
  80867. * @param babylonScene Babylon Scene
  80868. * @param nodes Babylon transform nodes
  80869. * @param binaryWriter Buffer to write binary data to
  80870. * @returns Node mapping of unique id to index
  80871. */
  80872. private createNodeMapAndAnimationsAsync;
  80873. /**
  80874. * Creates a glTF node from a Babylon mesh
  80875. * @param babylonMesh Source Babylon mesh
  80876. * @param binaryWriter Buffer for storing geometry data
  80877. * @param convertToRightHandedSystem Converts the values to right-handed
  80878. * @param nodeMap Node mapping of unique id to glTF node index
  80879. * @returns glTF node
  80880. */
  80881. private createNodeAsync;
  80882. }
  80883. /**
  80884. * @hidden
  80885. *
  80886. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  80887. */
  80888. export class _BinaryWriter {
  80889. /**
  80890. * Array buffer which stores all binary data
  80891. */
  80892. private _arrayBuffer;
  80893. /**
  80894. * View of the array buffer
  80895. */
  80896. private _dataView;
  80897. /**
  80898. * byte offset of data in array buffer
  80899. */
  80900. private _byteOffset;
  80901. /**
  80902. * Initialize binary writer with an initial byte length
  80903. * @param byteLength Initial byte length of the array buffer
  80904. */
  80905. constructor(byteLength: number);
  80906. /**
  80907. * Resize the array buffer to the specified byte length
  80908. * @param byteLength
  80909. */
  80910. private resizeBuffer;
  80911. /**
  80912. * Get an array buffer with the length of the byte offset
  80913. * @returns ArrayBuffer resized to the byte offset
  80914. */
  80915. getArrayBuffer(): ArrayBuffer;
  80916. /**
  80917. * Get the byte offset of the array buffer
  80918. * @returns byte offset
  80919. */
  80920. getByteOffset(): number;
  80921. /**
  80922. * Stores an UInt8 in the array buffer
  80923. * @param entry
  80924. * @param byteOffset If defined, specifies where to set the value as an offset.
  80925. */
  80926. setUInt8(entry: number, byteOffset?: number): void;
  80927. /**
  80928. * Gets an UInt32 in the array buffer
  80929. * @param entry
  80930. * @param byteOffset If defined, specifies where to set the value as an offset.
  80931. */
  80932. getUInt32(byteOffset: number): number;
  80933. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  80934. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  80935. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  80936. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  80937. /**
  80938. * Stores a Float32 in the array buffer
  80939. * @param entry
  80940. */
  80941. setFloat32(entry: number, byteOffset?: number): void;
  80942. /**
  80943. * Stores an UInt32 in the array buffer
  80944. * @param entry
  80945. * @param byteOffset If defined, specifies where to set the value as an offset.
  80946. */
  80947. setUInt32(entry: number, byteOffset?: number): void;
  80948. }
  80949. }
  80950. declare module BABYLON.GLTF2.Exporter {
  80951. /**
  80952. * @hidden
  80953. * Interface to store animation data.
  80954. */
  80955. export interface _IAnimationData {
  80956. /**
  80957. * Keyframe data.
  80958. */
  80959. inputs: number[];
  80960. /**
  80961. * Value data.
  80962. */
  80963. outputs: number[][];
  80964. /**
  80965. * Animation interpolation data.
  80966. */
  80967. samplerInterpolation: AnimationSamplerInterpolation;
  80968. /**
  80969. * Minimum keyframe value.
  80970. */
  80971. inputsMin: number;
  80972. /**
  80973. * Maximum keyframe value.
  80974. */
  80975. inputsMax: number;
  80976. }
  80977. /**
  80978. * @hidden
  80979. */
  80980. export interface _IAnimationInfo {
  80981. /**
  80982. * The target channel for the animation
  80983. */
  80984. animationChannelTargetPath: AnimationChannelTargetPath;
  80985. /**
  80986. * The glTF accessor type for the data.
  80987. */
  80988. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  80989. /**
  80990. * Specifies if quaternions should be used.
  80991. */
  80992. useQuaternion: boolean;
  80993. }
  80994. /**
  80995. * @hidden
  80996. * Utility class for generating glTF animation data from BabylonJS.
  80997. */
  80998. export class _GLTFAnimation {
  80999. /**
  81000. * @ignore
  81001. *
  81002. * Creates glTF channel animation from BabylonJS animation.
  81003. * @param babylonTransformNode - BabylonJS mesh.
  81004. * @param animation - animation.
  81005. * @param animationChannelTargetPath - The target animation channel.
  81006. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  81007. * @param useQuaternion - Specifies if quaternions are used.
  81008. * @returns nullable IAnimationData
  81009. */
  81010. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  81011. private static _DeduceAnimationInfo;
  81012. /**
  81013. * @ignore
  81014. * Create node animations from the transform node animations
  81015. * @param babylonNode
  81016. * @param runtimeGLTFAnimation
  81017. * @param idleGLTFAnimations
  81018. * @param nodeMap
  81019. * @param nodes
  81020. * @param binaryWriter
  81021. * @param bufferViews
  81022. * @param accessors
  81023. * @param convertToRightHandedSystem
  81024. * @param animationSampleRate
  81025. */
  81026. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  81027. [key: number]: number;
  81028. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  81029. /**
  81030. * @ignore
  81031. * Create node animations from the animation groups
  81032. * @param babylonScene
  81033. * @param glTFAnimations
  81034. * @param nodeMap
  81035. * @param nodes
  81036. * @param binaryWriter
  81037. * @param bufferViews
  81038. * @param accessors
  81039. * @param convertToRightHandedSystemMap
  81040. * @param animationSampleRate
  81041. */
  81042. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  81043. [key: number]: number;
  81044. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  81045. [nodeId: number]: boolean;
  81046. }, animationSampleRate: number): void;
  81047. private static AddAnimation;
  81048. /**
  81049. * Create a baked animation
  81050. * @param babylonTransformNode BabylonJS mesh
  81051. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  81052. * @param animationChannelTargetPath animation target channel
  81053. * @param minFrame minimum animation frame
  81054. * @param maxFrame maximum animation frame
  81055. * @param fps frames per second of the animation
  81056. * @param inputs input key frames of the animation
  81057. * @param outputs output key frame data of the animation
  81058. * @param convertToRightHandedSystem converts the values to right-handed
  81059. * @param useQuaternion specifies if quaternions should be used
  81060. */
  81061. private static _CreateBakedAnimation;
  81062. private static _ConvertFactorToVector3OrQuaternion;
  81063. private static _SetInterpolatedValue;
  81064. /**
  81065. * Creates linear animation from the animation key frames
  81066. * @param babylonTransformNode BabylonJS mesh
  81067. * @param animation BabylonJS animation
  81068. * @param animationChannelTargetPath The target animation channel
  81069. * @param frameDelta The difference between the last and first frame of the animation
  81070. * @param inputs Array to store the key frame times
  81071. * @param outputs Array to store the key frame data
  81072. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81073. * @param useQuaternion Specifies if quaternions are used in the animation
  81074. */
  81075. private static _CreateLinearOrStepAnimation;
  81076. /**
  81077. * Creates cubic spline animation from the animation key frames
  81078. * @param babylonTransformNode BabylonJS mesh
  81079. * @param animation BabylonJS animation
  81080. * @param animationChannelTargetPath The target animation channel
  81081. * @param frameDelta The difference between the last and first frame of the animation
  81082. * @param inputs Array to store the key frame times
  81083. * @param outputs Array to store the key frame data
  81084. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81085. * @param useQuaternion Specifies if quaternions are used in the animation
  81086. */
  81087. private static _CreateCubicSplineAnimation;
  81088. private static _GetBasePositionRotationOrScale;
  81089. /**
  81090. * Adds a key frame value
  81091. * @param keyFrame
  81092. * @param animation
  81093. * @param outputs
  81094. * @param animationChannelTargetPath
  81095. * @param basePositionRotationOrScale
  81096. * @param convertToRightHandedSystem
  81097. * @param useQuaternion
  81098. */
  81099. private static _AddKeyframeValue;
  81100. /**
  81101. * Determine the interpolation based on the key frames
  81102. * @param keyFrames
  81103. * @param animationChannelTargetPath
  81104. * @param useQuaternion
  81105. */
  81106. private static _DeduceInterpolation;
  81107. /**
  81108. * Adds an input tangent or output tangent to the output data
  81109. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81110. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81111. * @param outputs The animation data by keyframe
  81112. * @param animationChannelTargetPath The target animation channel
  81113. * @param interpolation The interpolation type
  81114. * @param keyFrame The key frame with the animation data
  81115. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81116. * @param useQuaternion Specifies if quaternions are used
  81117. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81118. */
  81119. private static AddSplineTangent;
  81120. /**
  81121. * Get the minimum and maximum key frames' frame values
  81122. * @param keyFrames animation key frames
  81123. * @returns the minimum and maximum key frame value
  81124. */
  81125. private static calculateMinMaxKeyFrames;
  81126. }
  81127. }
  81128. declare module BABYLON.GLTF2.Exporter {
  81129. /** @hidden */
  81130. export var textureTransformPixelShader: {
  81131. name: string;
  81132. shader: string;
  81133. };
  81134. }
  81135. declare module BABYLON.GLTF2.Exporter.Extensions {
  81136. /**
  81137. * @hidden
  81138. */
  81139. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81140. private _recordedTextures;
  81141. /** Name of this extension */
  81142. readonly name: string;
  81143. /** Defines whether this extension is enabled */
  81144. enabled: boolean;
  81145. /** Defines whether this extension is required */
  81146. required: boolean;
  81147. /** Reference to the glTF exporter */
  81148. private _wasUsed;
  81149. constructor(exporter: _Exporter);
  81150. dispose(): void;
  81151. /** @hidden */
  81152. get wasUsed(): boolean;
  81153. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81154. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81155. /**
  81156. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81157. * @param babylonTexture
  81158. * @param offset
  81159. * @param rotation
  81160. * @param scale
  81161. * @param scene
  81162. */
  81163. private _textureTransformTextureAsync;
  81164. }
  81165. }
  81166. declare module BABYLON.GLTF2.Exporter.Extensions {
  81167. /**
  81168. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81169. */
  81170. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81171. /** The name of this extension. */
  81172. readonly name: string;
  81173. /** Defines whether this extension is enabled. */
  81174. enabled: boolean;
  81175. /** Defines whether this extension is required */
  81176. required: boolean;
  81177. /** Reference to the glTF exporter */
  81178. private _exporter;
  81179. private _lights;
  81180. /** @hidden */
  81181. constructor(exporter: _Exporter);
  81182. /** @hidden */
  81183. dispose(): void;
  81184. /** @hidden */
  81185. get wasUsed(): boolean;
  81186. /** @hidden */
  81187. onExporting(): void;
  81188. /**
  81189. * Define this method to modify the default behavior when exporting a node
  81190. * @param context The context when exporting the node
  81191. * @param node glTF node
  81192. * @param babylonNode BabylonJS node
  81193. * @param nodeMap Node mapping of unique id to glTF node index
  81194. * @returns nullable INode promise
  81195. */
  81196. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81197. [key: number]: number;
  81198. }): Promise<Nullable<INode>>;
  81199. }
  81200. }
  81201. declare module BABYLON.GLTF2.Exporter.Extensions {
  81202. /**
  81203. * @hidden
  81204. */
  81205. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81206. /** Name of this extension */
  81207. readonly name: string;
  81208. /** Defines whether this extension is enabled */
  81209. enabled: boolean;
  81210. /** Defines whether this extension is required */
  81211. required: boolean;
  81212. /** Reference to the glTF exporter */
  81213. private _textureInfos;
  81214. private _exportedTextures;
  81215. private _wasUsed;
  81216. constructor(exporter: _Exporter);
  81217. dispose(): void;
  81218. /** @hidden */
  81219. get wasUsed(): boolean;
  81220. private _getTextureIndex;
  81221. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81222. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81223. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81224. }
  81225. }
  81226. declare module BABYLON {
  81227. /**
  81228. * Class for generating STL data from a Babylon scene.
  81229. */
  81230. export class STLExport {
  81231. /**
  81232. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81233. * @param meshes list defines the mesh to serialize
  81234. * @param download triggers the automatic download of the file.
  81235. * @param fileName changes the downloads fileName.
  81236. * @param binary changes the STL to a binary type.
  81237. * @param isLittleEndian toggle for binary type exporter.
  81238. * @returns the STL as UTF8 string
  81239. */
  81240. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81241. }
  81242. }
  81243. declare module "babylonjs-gltf2interface" {
  81244. export = BABYLON.GLTF2;
  81245. }
  81246. /**
  81247. * Module for glTF 2.0 Interface
  81248. */
  81249. declare module BABYLON.GLTF2 {
  81250. /**
  81251. * The datatype of the components in the attribute
  81252. */
  81253. const enum AccessorComponentType {
  81254. /**
  81255. * Byte
  81256. */
  81257. BYTE = 5120,
  81258. /**
  81259. * Unsigned Byte
  81260. */
  81261. UNSIGNED_BYTE = 5121,
  81262. /**
  81263. * Short
  81264. */
  81265. SHORT = 5122,
  81266. /**
  81267. * Unsigned Short
  81268. */
  81269. UNSIGNED_SHORT = 5123,
  81270. /**
  81271. * Unsigned Int
  81272. */
  81273. UNSIGNED_INT = 5125,
  81274. /**
  81275. * Float
  81276. */
  81277. FLOAT = 5126,
  81278. }
  81279. /**
  81280. * Specifies if the attirbute is a scalar, vector, or matrix
  81281. */
  81282. const enum AccessorType {
  81283. /**
  81284. * Scalar
  81285. */
  81286. SCALAR = "SCALAR",
  81287. /**
  81288. * Vector2
  81289. */
  81290. VEC2 = "VEC2",
  81291. /**
  81292. * Vector3
  81293. */
  81294. VEC3 = "VEC3",
  81295. /**
  81296. * Vector4
  81297. */
  81298. VEC4 = "VEC4",
  81299. /**
  81300. * Matrix2x2
  81301. */
  81302. MAT2 = "MAT2",
  81303. /**
  81304. * Matrix3x3
  81305. */
  81306. MAT3 = "MAT3",
  81307. /**
  81308. * Matrix4x4
  81309. */
  81310. MAT4 = "MAT4",
  81311. }
  81312. /**
  81313. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81314. */
  81315. const enum AnimationChannelTargetPath {
  81316. /**
  81317. * Translation
  81318. */
  81319. TRANSLATION = "translation",
  81320. /**
  81321. * Rotation
  81322. */
  81323. ROTATION = "rotation",
  81324. /**
  81325. * Scale
  81326. */
  81327. SCALE = "scale",
  81328. /**
  81329. * Weights
  81330. */
  81331. WEIGHTS = "weights",
  81332. }
  81333. /**
  81334. * Interpolation algorithm
  81335. */
  81336. const enum AnimationSamplerInterpolation {
  81337. /**
  81338. * The animated values are linearly interpolated between keyframes
  81339. */
  81340. LINEAR = "LINEAR",
  81341. /**
  81342. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  81343. */
  81344. STEP = "STEP",
  81345. /**
  81346. * The animation's interpolation is computed using a cubic spline with specified tangents
  81347. */
  81348. CUBICSPLINE = "CUBICSPLINE",
  81349. }
  81350. /**
  81351. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81352. */
  81353. const enum CameraType {
  81354. /**
  81355. * A perspective camera containing properties to create a perspective projection matrix
  81356. */
  81357. PERSPECTIVE = "perspective",
  81358. /**
  81359. * An orthographic camera containing properties to create an orthographic projection matrix
  81360. */
  81361. ORTHOGRAPHIC = "orthographic",
  81362. }
  81363. /**
  81364. * The mime-type of the image
  81365. */
  81366. const enum ImageMimeType {
  81367. /**
  81368. * JPEG Mime-type
  81369. */
  81370. JPEG = "image/jpeg",
  81371. /**
  81372. * PNG Mime-type
  81373. */
  81374. PNG = "image/png",
  81375. }
  81376. /**
  81377. * The alpha rendering mode of the material
  81378. */
  81379. const enum MaterialAlphaMode {
  81380. /**
  81381. * The alpha value is ignored and the rendered output is fully opaque
  81382. */
  81383. OPAQUE = "OPAQUE",
  81384. /**
  81385. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  81386. */
  81387. MASK = "MASK",
  81388. /**
  81389. * 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)
  81390. */
  81391. BLEND = "BLEND",
  81392. }
  81393. /**
  81394. * The type of the primitives to render
  81395. */
  81396. const enum MeshPrimitiveMode {
  81397. /**
  81398. * Points
  81399. */
  81400. POINTS = 0,
  81401. /**
  81402. * Lines
  81403. */
  81404. LINES = 1,
  81405. /**
  81406. * Line Loop
  81407. */
  81408. LINE_LOOP = 2,
  81409. /**
  81410. * Line Strip
  81411. */
  81412. LINE_STRIP = 3,
  81413. /**
  81414. * Triangles
  81415. */
  81416. TRIANGLES = 4,
  81417. /**
  81418. * Triangle Strip
  81419. */
  81420. TRIANGLE_STRIP = 5,
  81421. /**
  81422. * Triangle Fan
  81423. */
  81424. TRIANGLE_FAN = 6,
  81425. }
  81426. /**
  81427. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81428. */
  81429. const enum TextureMagFilter {
  81430. /**
  81431. * Nearest
  81432. */
  81433. NEAREST = 9728,
  81434. /**
  81435. * Linear
  81436. */
  81437. LINEAR = 9729,
  81438. }
  81439. /**
  81440. * Minification filter. All valid values correspond to WebGL enums
  81441. */
  81442. const enum TextureMinFilter {
  81443. /**
  81444. * Nearest
  81445. */
  81446. NEAREST = 9728,
  81447. /**
  81448. * Linear
  81449. */
  81450. LINEAR = 9729,
  81451. /**
  81452. * Nearest Mip-Map Nearest
  81453. */
  81454. NEAREST_MIPMAP_NEAREST = 9984,
  81455. /**
  81456. * Linear Mipmap Nearest
  81457. */
  81458. LINEAR_MIPMAP_NEAREST = 9985,
  81459. /**
  81460. * Nearest Mipmap Linear
  81461. */
  81462. NEAREST_MIPMAP_LINEAR = 9986,
  81463. /**
  81464. * Linear Mipmap Linear
  81465. */
  81466. LINEAR_MIPMAP_LINEAR = 9987,
  81467. }
  81468. /**
  81469. * S (U) wrapping mode. All valid values correspond to WebGL enums
  81470. */
  81471. const enum TextureWrapMode {
  81472. /**
  81473. * Clamp to Edge
  81474. */
  81475. CLAMP_TO_EDGE = 33071,
  81476. /**
  81477. * Mirrored Repeat
  81478. */
  81479. MIRRORED_REPEAT = 33648,
  81480. /**
  81481. * Repeat
  81482. */
  81483. REPEAT = 10497,
  81484. }
  81485. /**
  81486. * glTF Property
  81487. */
  81488. interface IProperty {
  81489. /**
  81490. * Dictionary object with extension-specific objects
  81491. */
  81492. extensions?: {
  81493. [key: string]: any;
  81494. };
  81495. /**
  81496. * Application-Specific data
  81497. */
  81498. extras?: any;
  81499. }
  81500. /**
  81501. * glTF Child of Root Property
  81502. */
  81503. interface IChildRootProperty extends IProperty {
  81504. /**
  81505. * The user-defined name of this object
  81506. */
  81507. name?: string;
  81508. }
  81509. /**
  81510. * Indices of those attributes that deviate from their initialization value
  81511. */
  81512. interface IAccessorSparseIndices extends IProperty {
  81513. /**
  81514. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81515. */
  81516. bufferView: number;
  81517. /**
  81518. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81519. */
  81520. byteOffset?: number;
  81521. /**
  81522. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  81523. */
  81524. componentType: AccessorComponentType;
  81525. }
  81526. /**
  81527. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  81528. */
  81529. interface IAccessorSparseValues extends IProperty {
  81530. /**
  81531. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81532. */
  81533. bufferView: number;
  81534. /**
  81535. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81536. */
  81537. byteOffset?: number;
  81538. }
  81539. /**
  81540. * Sparse storage of attributes that deviate from their initialization value
  81541. */
  81542. interface IAccessorSparse extends IProperty {
  81543. /**
  81544. * The number of attributes encoded in this sparse accessor
  81545. */
  81546. count: number;
  81547. /**
  81548. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  81549. */
  81550. indices: IAccessorSparseIndices;
  81551. /**
  81552. * 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
  81553. */
  81554. values: IAccessorSparseValues;
  81555. }
  81556. /**
  81557. * 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
  81558. */
  81559. interface IAccessor extends IChildRootProperty {
  81560. /**
  81561. * The index of the bufferview
  81562. */
  81563. bufferView?: number;
  81564. /**
  81565. * The offset relative to the start of the bufferView in bytes
  81566. */
  81567. byteOffset?: number;
  81568. /**
  81569. * The datatype of components in the attribute
  81570. */
  81571. componentType: AccessorComponentType;
  81572. /**
  81573. * Specifies whether integer data values should be normalized
  81574. */
  81575. normalized?: boolean;
  81576. /**
  81577. * The number of attributes referenced by this accessor
  81578. */
  81579. count: number;
  81580. /**
  81581. * Specifies if the attribute is a scalar, vector, or matrix
  81582. */
  81583. type: AccessorType;
  81584. /**
  81585. * Maximum value of each component in this attribute
  81586. */
  81587. max?: number[];
  81588. /**
  81589. * Minimum value of each component in this attribute
  81590. */
  81591. min?: number[];
  81592. /**
  81593. * Sparse storage of attributes that deviate from their initialization value
  81594. */
  81595. sparse?: IAccessorSparse;
  81596. }
  81597. /**
  81598. * Targets an animation's sampler at a node's property
  81599. */
  81600. interface IAnimationChannel extends IProperty {
  81601. /**
  81602. * The index of a sampler in this animation used to compute the value for the target
  81603. */
  81604. sampler: number;
  81605. /**
  81606. * The index of the node and TRS property to target
  81607. */
  81608. target: IAnimationChannelTarget;
  81609. }
  81610. /**
  81611. * The index of the node and TRS property that an animation channel targets
  81612. */
  81613. interface IAnimationChannelTarget extends IProperty {
  81614. /**
  81615. * The index of the node to target
  81616. */
  81617. node: number;
  81618. /**
  81619. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81620. */
  81621. path: AnimationChannelTargetPath;
  81622. }
  81623. /**
  81624. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81625. */
  81626. interface IAnimationSampler extends IProperty {
  81627. /**
  81628. * The index of an accessor containing keyframe input values, e.g., time
  81629. */
  81630. input: number;
  81631. /**
  81632. * Interpolation algorithm
  81633. */
  81634. interpolation?: AnimationSamplerInterpolation;
  81635. /**
  81636. * The index of an accessor, containing keyframe output values
  81637. */
  81638. output: number;
  81639. }
  81640. /**
  81641. * A keyframe animation
  81642. */
  81643. interface IAnimation extends IChildRootProperty {
  81644. /**
  81645. * An array of channels, each of which targets an animation's sampler at a node's property
  81646. */
  81647. channels: IAnimationChannel[];
  81648. /**
  81649. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81650. */
  81651. samplers: IAnimationSampler[];
  81652. }
  81653. /**
  81654. * Metadata about the glTF asset
  81655. */
  81656. interface IAsset extends IChildRootProperty {
  81657. /**
  81658. * A copyright message suitable for display to credit the content creator
  81659. */
  81660. copyright?: string;
  81661. /**
  81662. * Tool that generated this glTF model. Useful for debugging
  81663. */
  81664. generator?: string;
  81665. /**
  81666. * The glTF version that this asset targets
  81667. */
  81668. version: string;
  81669. /**
  81670. * The minimum glTF version that this asset targets
  81671. */
  81672. minVersion?: string;
  81673. }
  81674. /**
  81675. * A buffer points to binary geometry, animation, or skins
  81676. */
  81677. interface IBuffer extends IChildRootProperty {
  81678. /**
  81679. * 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
  81680. */
  81681. uri?: string;
  81682. /**
  81683. * The length of the buffer in bytes
  81684. */
  81685. byteLength: number;
  81686. }
  81687. /**
  81688. * A view into a buffer generally representing a subset of the buffer
  81689. */
  81690. interface IBufferView extends IChildRootProperty {
  81691. /**
  81692. * The index of the buffer
  81693. */
  81694. buffer: number;
  81695. /**
  81696. * The offset into the buffer in bytes
  81697. */
  81698. byteOffset?: number;
  81699. /**
  81700. * The lenth of the bufferView in bytes
  81701. */
  81702. byteLength: number;
  81703. /**
  81704. * The stride, in bytes
  81705. */
  81706. byteStride?: number;
  81707. }
  81708. /**
  81709. * An orthographic camera containing properties to create an orthographic projection matrix
  81710. */
  81711. interface ICameraOrthographic extends IProperty {
  81712. /**
  81713. * The floating-point horizontal magnification of the view. Must not be zero
  81714. */
  81715. xmag: number;
  81716. /**
  81717. * The floating-point vertical magnification of the view. Must not be zero
  81718. */
  81719. ymag: number;
  81720. /**
  81721. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  81722. */
  81723. zfar: number;
  81724. /**
  81725. * The floating-point distance to the near clipping plane
  81726. */
  81727. znear: number;
  81728. }
  81729. /**
  81730. * A perspective camera containing properties to create a perspective projection matrix
  81731. */
  81732. interface ICameraPerspective extends IProperty {
  81733. /**
  81734. * The floating-point aspect ratio of the field of view
  81735. */
  81736. aspectRatio?: number;
  81737. /**
  81738. * The floating-point vertical field of view in radians
  81739. */
  81740. yfov: number;
  81741. /**
  81742. * The floating-point distance to the far clipping plane
  81743. */
  81744. zfar?: number;
  81745. /**
  81746. * The floating-point distance to the near clipping plane
  81747. */
  81748. znear: number;
  81749. }
  81750. /**
  81751. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81752. */
  81753. interface ICamera extends IChildRootProperty {
  81754. /**
  81755. * An orthographic camera containing properties to create an orthographic projection matrix
  81756. */
  81757. orthographic?: ICameraOrthographic;
  81758. /**
  81759. * A perspective camera containing properties to create a perspective projection matrix
  81760. */
  81761. perspective?: ICameraPerspective;
  81762. /**
  81763. * Specifies if the camera uses a perspective or orthographic projection
  81764. */
  81765. type: CameraType;
  81766. }
  81767. /**
  81768. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  81769. */
  81770. interface IImage extends IChildRootProperty {
  81771. /**
  81772. * 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
  81773. */
  81774. uri?: string;
  81775. /**
  81776. * The image's MIME type
  81777. */
  81778. mimeType?: ImageMimeType;
  81779. /**
  81780. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  81781. */
  81782. bufferView?: number;
  81783. }
  81784. /**
  81785. * Material Normal Texture Info
  81786. */
  81787. interface IMaterialNormalTextureInfo extends ITextureInfo {
  81788. /**
  81789. * The scalar multiplier applied to each normal vector of the normal texture
  81790. */
  81791. scale?: number;
  81792. }
  81793. /**
  81794. * Material Occlusion Texture Info
  81795. */
  81796. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  81797. /**
  81798. * A scalar multiplier controlling the amount of occlusion applied
  81799. */
  81800. strength?: number;
  81801. }
  81802. /**
  81803. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  81804. */
  81805. interface IMaterialPbrMetallicRoughness {
  81806. /**
  81807. * The material's base color factor
  81808. */
  81809. baseColorFactor?: number[];
  81810. /**
  81811. * The base color texture
  81812. */
  81813. baseColorTexture?: ITextureInfo;
  81814. /**
  81815. * The metalness of the material
  81816. */
  81817. metallicFactor?: number;
  81818. /**
  81819. * The roughness of the material
  81820. */
  81821. roughnessFactor?: number;
  81822. /**
  81823. * The metallic-roughness texture
  81824. */
  81825. metallicRoughnessTexture?: ITextureInfo;
  81826. }
  81827. /**
  81828. * The material appearance of a primitive
  81829. */
  81830. interface IMaterial extends IChildRootProperty {
  81831. /**
  81832. * 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
  81833. */
  81834. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81835. /**
  81836. * The normal map texture
  81837. */
  81838. normalTexture?: IMaterialNormalTextureInfo;
  81839. /**
  81840. * The occlusion map texture
  81841. */
  81842. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81843. /**
  81844. * The emissive map texture
  81845. */
  81846. emissiveTexture?: ITextureInfo;
  81847. /**
  81848. * 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
  81849. */
  81850. emissiveFactor?: number[];
  81851. /**
  81852. * The alpha rendering mode of the material
  81853. */
  81854. alphaMode?: MaterialAlphaMode;
  81855. /**
  81856. * The alpha cutoff value of the material
  81857. */
  81858. alphaCutoff?: number;
  81859. /**
  81860. * Specifies whether the material is double sided
  81861. */
  81862. doubleSided?: boolean;
  81863. }
  81864. /**
  81865. * Geometry to be rendered with the given material
  81866. */
  81867. interface IMeshPrimitive extends IProperty {
  81868. /**
  81869. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  81870. */
  81871. attributes: {
  81872. [name: string]: number;
  81873. };
  81874. /**
  81875. * The index of the accessor that contains the indices
  81876. */
  81877. indices?: number;
  81878. /**
  81879. * The index of the material to apply to this primitive when rendering
  81880. */
  81881. material?: number;
  81882. /**
  81883. * The type of primitives to render. All valid values correspond to WebGL enums
  81884. */
  81885. mode?: MeshPrimitiveMode;
  81886. /**
  81887. * 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
  81888. */
  81889. targets?: {
  81890. [name: string]: number;
  81891. }[];
  81892. }
  81893. /**
  81894. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  81895. */
  81896. interface IMesh extends IChildRootProperty {
  81897. /**
  81898. * An array of primitives, each defining geometry to be rendered with a material
  81899. */
  81900. primitives: IMeshPrimitive[];
  81901. /**
  81902. * Array of weights to be applied to the Morph Targets
  81903. */
  81904. weights?: number[];
  81905. }
  81906. /**
  81907. * A node in the node hierarchy
  81908. */
  81909. interface INode extends IChildRootProperty {
  81910. /**
  81911. * The index of the camera referenced by this node
  81912. */
  81913. camera?: number;
  81914. /**
  81915. * The indices of this node's children
  81916. */
  81917. children?: number[];
  81918. /**
  81919. * The index of the skin referenced by this node
  81920. */
  81921. skin?: number;
  81922. /**
  81923. * A floating-point 4x4 transformation matrix stored in column-major order
  81924. */
  81925. matrix?: number[];
  81926. /**
  81927. * The index of the mesh in this node
  81928. */
  81929. mesh?: number;
  81930. /**
  81931. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  81932. */
  81933. rotation?: number[];
  81934. /**
  81935. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  81936. */
  81937. scale?: number[];
  81938. /**
  81939. * The node's translation along the x, y, and z axes
  81940. */
  81941. translation?: number[];
  81942. /**
  81943. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  81944. */
  81945. weights?: number[];
  81946. }
  81947. /**
  81948. * Texture sampler properties for filtering and wrapping modes
  81949. */
  81950. interface ISampler extends IChildRootProperty {
  81951. /**
  81952. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81953. */
  81954. magFilter?: TextureMagFilter;
  81955. /**
  81956. * Minification filter. All valid values correspond to WebGL enums
  81957. */
  81958. minFilter?: TextureMinFilter;
  81959. /**
  81960. * S (U) wrapping mode. All valid values correspond to WebGL enums
  81961. */
  81962. wrapS?: TextureWrapMode;
  81963. /**
  81964. * T (V) wrapping mode. All valid values correspond to WebGL enums
  81965. */
  81966. wrapT?: TextureWrapMode;
  81967. }
  81968. /**
  81969. * The root nodes of a scene
  81970. */
  81971. interface IScene extends IChildRootProperty {
  81972. /**
  81973. * The indices of each root node
  81974. */
  81975. nodes: number[];
  81976. }
  81977. /**
  81978. * Joints and matrices defining a skin
  81979. */
  81980. interface ISkin extends IChildRootProperty {
  81981. /**
  81982. * 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
  81983. */
  81984. inverseBindMatrices?: number;
  81985. /**
  81986. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  81987. */
  81988. skeleton?: number;
  81989. /**
  81990. * 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)
  81991. */
  81992. joints: number[];
  81993. }
  81994. /**
  81995. * A texture and its sampler
  81996. */
  81997. interface ITexture extends IChildRootProperty {
  81998. /**
  81999. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  82000. */
  82001. sampler?: number;
  82002. /**
  82003. * The index of the image used by this texture
  82004. */
  82005. source: number;
  82006. }
  82007. /**
  82008. * Reference to a texture
  82009. */
  82010. interface ITextureInfo extends IProperty {
  82011. /**
  82012. * The index of the texture
  82013. */
  82014. index: number;
  82015. /**
  82016. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  82017. */
  82018. texCoord?: number;
  82019. }
  82020. /**
  82021. * The root object for a glTF asset
  82022. */
  82023. interface IGLTF extends IProperty {
  82024. /**
  82025. * An array of accessors. An accessor is a typed view into a bufferView
  82026. */
  82027. accessors?: IAccessor[];
  82028. /**
  82029. * An array of keyframe animations
  82030. */
  82031. animations?: IAnimation[];
  82032. /**
  82033. * Metadata about the glTF asset
  82034. */
  82035. asset: IAsset;
  82036. /**
  82037. * An array of buffers. A buffer points to binary geometry, animation, or skins
  82038. */
  82039. buffers?: IBuffer[];
  82040. /**
  82041. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  82042. */
  82043. bufferViews?: IBufferView[];
  82044. /**
  82045. * An array of cameras
  82046. */
  82047. cameras?: ICamera[];
  82048. /**
  82049. * Names of glTF extensions used somewhere in this asset
  82050. */
  82051. extensionsUsed?: string[];
  82052. /**
  82053. * Names of glTF extensions required to properly load this asset
  82054. */
  82055. extensionsRequired?: string[];
  82056. /**
  82057. * An array of images. An image defines data used to create a texture
  82058. */
  82059. images?: IImage[];
  82060. /**
  82061. * An array of materials. A material defines the appearance of a primitive
  82062. */
  82063. materials?: IMaterial[];
  82064. /**
  82065. * An array of meshes. A mesh is a set of primitives to be rendered
  82066. */
  82067. meshes?: IMesh[];
  82068. /**
  82069. * An array of nodes
  82070. */
  82071. nodes?: INode[];
  82072. /**
  82073. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82074. */
  82075. samplers?: ISampler[];
  82076. /**
  82077. * The index of the default scene
  82078. */
  82079. scene?: number;
  82080. /**
  82081. * An array of scenes
  82082. */
  82083. scenes?: IScene[];
  82084. /**
  82085. * An array of skins. A skin is defined by joints and matrices
  82086. */
  82087. skins?: ISkin[];
  82088. /**
  82089. * An array of textures
  82090. */
  82091. textures?: ITexture[];
  82092. }
  82093. /**
  82094. * The glTF validation results
  82095. * @ignore
  82096. */
  82097. interface IGLTFValidationResults {
  82098. info: {
  82099. generator: string;
  82100. hasAnimations: boolean;
  82101. hasDefaultScene: boolean;
  82102. hasMaterials: boolean;
  82103. hasMorphTargets: boolean;
  82104. hasSkins: boolean;
  82105. hasTextures: boolean;
  82106. maxAttributesUsed: number;
  82107. primitivesCount: number
  82108. };
  82109. issues: {
  82110. messages: Array<string>;
  82111. numErrors: number;
  82112. numHints: number;
  82113. numInfos: number;
  82114. numWarnings: number;
  82115. truncated: boolean
  82116. };
  82117. mimeType: string;
  82118. uri: string;
  82119. validatedAt: string;
  82120. validatorVersion: string;
  82121. }
  82122. /**
  82123. * The glTF validation options
  82124. */
  82125. interface IGLTFValidationOptions {
  82126. /** Uri to use */
  82127. uri?: string;
  82128. /** Function used to load external resources */
  82129. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82130. /** Boolean indicating that we need to validate accessor data */
  82131. validateAccessorData?: boolean;
  82132. /** max number of issues allowed */
  82133. maxIssues?: number;
  82134. /** Ignored issues */
  82135. ignoredIssues?: Array<string>;
  82136. /** Value to override severy settings */
  82137. severityOverrides?: Object;
  82138. }
  82139. /**
  82140. * The glTF validator object
  82141. * @ignore
  82142. */
  82143. interface IGLTFValidator {
  82144. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82145. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82146. }
  82147. }
  82148. declare module BABYLON {
  82149. /** @hidden */
  82150. export var cellPixelShader: {
  82151. name: string;
  82152. shader: string;
  82153. };
  82154. }
  82155. declare module BABYLON {
  82156. /** @hidden */
  82157. export var cellVertexShader: {
  82158. name: string;
  82159. shader: string;
  82160. };
  82161. }
  82162. declare module BABYLON {
  82163. export class CellMaterial extends BABYLON.PushMaterial {
  82164. private _diffuseTexture;
  82165. diffuseTexture: BABYLON.BaseTexture;
  82166. diffuseColor: BABYLON.Color3;
  82167. _computeHighLevel: boolean;
  82168. computeHighLevel: boolean;
  82169. private _disableLighting;
  82170. disableLighting: boolean;
  82171. private _maxSimultaneousLights;
  82172. maxSimultaneousLights: number;
  82173. constructor(name: string, scene: BABYLON.Scene);
  82174. needAlphaBlending(): boolean;
  82175. needAlphaTesting(): boolean;
  82176. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82177. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82178. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82179. getAnimatables(): BABYLON.IAnimatable[];
  82180. getActiveTextures(): BABYLON.BaseTexture[];
  82181. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82182. dispose(forceDisposeEffect?: boolean): void;
  82183. getClassName(): string;
  82184. clone(name: string): CellMaterial;
  82185. serialize(): any;
  82186. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82187. }
  82188. }
  82189. declare module BABYLON {
  82190. export class CustomShaderStructure {
  82191. FragmentStore: string;
  82192. VertexStore: string;
  82193. constructor();
  82194. }
  82195. export class ShaderSpecialParts {
  82196. constructor();
  82197. Fragment_Begin: string;
  82198. Fragment_Definitions: string;
  82199. Fragment_MainBegin: string;
  82200. Fragment_Custom_Diffuse: string;
  82201. Fragment_Before_Lights: string;
  82202. Fragment_Before_Fog: string;
  82203. Fragment_Custom_Alpha: string;
  82204. Fragment_Before_FragColor: string;
  82205. Vertex_Begin: string;
  82206. Vertex_Definitions: string;
  82207. Vertex_MainBegin: string;
  82208. Vertex_Before_PositionUpdated: string;
  82209. Vertex_Before_NormalUpdated: string;
  82210. Vertex_After_WorldPosComputed: string;
  82211. Vertex_MainEnd: string;
  82212. }
  82213. export class CustomMaterial extends BABYLON.StandardMaterial {
  82214. static ShaderIndexer: number;
  82215. CustomParts: ShaderSpecialParts;
  82216. _isCreatedShader: boolean;
  82217. _createdShaderName: string;
  82218. _customUniform: string[];
  82219. _newUniforms: string[];
  82220. _newUniformInstances: {
  82221. [name: string]: any;
  82222. };
  82223. _newSamplerInstances: {
  82224. [name: string]: BABYLON.Texture;
  82225. };
  82226. _customAttributes: string[];
  82227. FragmentShader: string;
  82228. VertexShader: string;
  82229. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82230. ReviewUniform(name: string, arr: string[]): string[];
  82231. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82232. constructor(name: string, scene: BABYLON.Scene);
  82233. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82234. AddAttribute(name: string): CustomMaterial;
  82235. Fragment_Begin(shaderPart: string): CustomMaterial;
  82236. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82237. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82238. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82239. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82240. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82241. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82242. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82243. Vertex_Begin(shaderPart: string): CustomMaterial;
  82244. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82245. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82246. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82247. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82248. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82249. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82250. }
  82251. }
  82252. declare module BABYLON {
  82253. export class ShaderAlebdoParts {
  82254. constructor();
  82255. Fragment_Begin: string;
  82256. Fragment_Definitions: string;
  82257. Fragment_MainBegin: string;
  82258. Fragment_Custom_Albedo: string;
  82259. Fragment_Before_Lights: string;
  82260. Fragment_Custom_MetallicRoughness: string;
  82261. Fragment_Custom_MicroSurface: string;
  82262. Fragment_Before_Fog: string;
  82263. Fragment_Custom_Alpha: string;
  82264. Fragment_Before_FragColor: string;
  82265. Vertex_Begin: string;
  82266. Vertex_Definitions: string;
  82267. Vertex_MainBegin: string;
  82268. Vertex_Before_PositionUpdated: string;
  82269. Vertex_Before_NormalUpdated: string;
  82270. Vertex_After_WorldPosComputed: string;
  82271. Vertex_MainEnd: string;
  82272. }
  82273. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  82274. static ShaderIndexer: number;
  82275. CustomParts: ShaderAlebdoParts;
  82276. _isCreatedShader: boolean;
  82277. _createdShaderName: string;
  82278. _customUniform: string[];
  82279. _newUniforms: string[];
  82280. _newUniformInstances: {
  82281. [name: string]: any;
  82282. };
  82283. _newSamplerInstances: {
  82284. [name: string]: BABYLON.Texture;
  82285. };
  82286. _customAttributes: string[];
  82287. FragmentShader: string;
  82288. VertexShader: string;
  82289. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82290. ReviewUniform(name: string, arr: string[]): string[];
  82291. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82292. constructor(name: string, scene: BABYLON.Scene);
  82293. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  82294. AddAttribute(name: string): PBRCustomMaterial;
  82295. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  82296. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  82297. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  82298. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  82299. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  82300. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  82301. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  82302. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  82303. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  82304. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  82305. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  82306. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  82307. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  82308. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  82309. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  82310. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  82311. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  82312. }
  82313. }
  82314. declare module BABYLON {
  82315. /** @hidden */
  82316. export var firePixelShader: {
  82317. name: string;
  82318. shader: string;
  82319. };
  82320. }
  82321. declare module BABYLON {
  82322. /** @hidden */
  82323. export var fireVertexShader: {
  82324. name: string;
  82325. shader: string;
  82326. };
  82327. }
  82328. declare module BABYLON {
  82329. export class FireMaterial extends BABYLON.PushMaterial {
  82330. private _diffuseTexture;
  82331. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82332. private _distortionTexture;
  82333. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82334. private _opacityTexture;
  82335. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82336. diffuseColor: BABYLON.Color3;
  82337. speed: number;
  82338. private _scaledDiffuse;
  82339. private _lastTime;
  82340. constructor(name: string, scene: BABYLON.Scene);
  82341. needAlphaBlending(): boolean;
  82342. needAlphaTesting(): boolean;
  82343. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82344. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82345. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82346. getAnimatables(): BABYLON.IAnimatable[];
  82347. getActiveTextures(): BABYLON.BaseTexture[];
  82348. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82349. getClassName(): string;
  82350. dispose(forceDisposeEffect?: boolean): void;
  82351. clone(name: string): FireMaterial;
  82352. serialize(): any;
  82353. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  82354. }
  82355. }
  82356. declare module BABYLON {
  82357. /** @hidden */
  82358. export var furPixelShader: {
  82359. name: string;
  82360. shader: string;
  82361. };
  82362. }
  82363. declare module BABYLON {
  82364. /** @hidden */
  82365. export var furVertexShader: {
  82366. name: string;
  82367. shader: string;
  82368. };
  82369. }
  82370. declare module BABYLON {
  82371. export class FurMaterial extends BABYLON.PushMaterial {
  82372. private _diffuseTexture;
  82373. diffuseTexture: BABYLON.BaseTexture;
  82374. private _heightTexture;
  82375. heightTexture: BABYLON.BaseTexture;
  82376. diffuseColor: BABYLON.Color3;
  82377. furLength: number;
  82378. furAngle: number;
  82379. furColor: BABYLON.Color3;
  82380. furOffset: number;
  82381. furSpacing: number;
  82382. furGravity: BABYLON.Vector3;
  82383. furSpeed: number;
  82384. furDensity: number;
  82385. furOcclusion: number;
  82386. furTexture: BABYLON.DynamicTexture;
  82387. private _disableLighting;
  82388. disableLighting: boolean;
  82389. private _maxSimultaneousLights;
  82390. maxSimultaneousLights: number;
  82391. highLevelFur: boolean;
  82392. _meshes: BABYLON.AbstractMesh[];
  82393. private _furTime;
  82394. constructor(name: string, scene: BABYLON.Scene);
  82395. get furTime(): number;
  82396. set furTime(furTime: number);
  82397. needAlphaBlending(): boolean;
  82398. needAlphaTesting(): boolean;
  82399. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82400. updateFur(): void;
  82401. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82402. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82403. getAnimatables(): BABYLON.IAnimatable[];
  82404. getActiveTextures(): BABYLON.BaseTexture[];
  82405. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82406. dispose(forceDisposeEffect?: boolean): void;
  82407. clone(name: string): FurMaterial;
  82408. serialize(): any;
  82409. getClassName(): string;
  82410. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  82411. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  82412. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  82413. }
  82414. }
  82415. declare module BABYLON {
  82416. /** @hidden */
  82417. export var gradientPixelShader: {
  82418. name: string;
  82419. shader: string;
  82420. };
  82421. }
  82422. declare module BABYLON {
  82423. /** @hidden */
  82424. export var gradientVertexShader: {
  82425. name: string;
  82426. shader: string;
  82427. };
  82428. }
  82429. declare module BABYLON {
  82430. export class GradientMaterial extends BABYLON.PushMaterial {
  82431. private _maxSimultaneousLights;
  82432. maxSimultaneousLights: number;
  82433. topColor: BABYLON.Color3;
  82434. topColorAlpha: number;
  82435. bottomColor: BABYLON.Color3;
  82436. bottomColorAlpha: number;
  82437. offset: number;
  82438. scale: number;
  82439. smoothness: number;
  82440. private _disableLighting;
  82441. disableLighting: boolean;
  82442. constructor(name: string, scene: BABYLON.Scene);
  82443. needAlphaBlending(): boolean;
  82444. needAlphaTesting(): boolean;
  82445. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82446. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82447. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82448. getAnimatables(): BABYLON.IAnimatable[];
  82449. dispose(forceDisposeEffect?: boolean): void;
  82450. clone(name: string): GradientMaterial;
  82451. serialize(): any;
  82452. getClassName(): string;
  82453. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  82454. }
  82455. }
  82456. declare module BABYLON {
  82457. /** @hidden */
  82458. export var gridPixelShader: {
  82459. name: string;
  82460. shader: string;
  82461. };
  82462. }
  82463. declare module BABYLON {
  82464. /** @hidden */
  82465. export var gridVertexShader: {
  82466. name: string;
  82467. shader: string;
  82468. };
  82469. }
  82470. declare module BABYLON {
  82471. /**
  82472. * The grid materials allows you to wrap any shape with a grid.
  82473. * Colors are customizable.
  82474. */
  82475. export class GridMaterial extends BABYLON.PushMaterial {
  82476. /**
  82477. * Main color of the grid (e.g. between lines)
  82478. */
  82479. mainColor: BABYLON.Color3;
  82480. /**
  82481. * Color of the grid lines.
  82482. */
  82483. lineColor: BABYLON.Color3;
  82484. /**
  82485. * The scale of the grid compared to unit.
  82486. */
  82487. gridRatio: number;
  82488. /**
  82489. * Allows setting an offset for the grid lines.
  82490. */
  82491. gridOffset: BABYLON.Vector3;
  82492. /**
  82493. * The frequency of thicker lines.
  82494. */
  82495. majorUnitFrequency: number;
  82496. /**
  82497. * The visibility of minor units in the grid.
  82498. */
  82499. minorUnitVisibility: number;
  82500. /**
  82501. * The grid opacity outside of the lines.
  82502. */
  82503. opacity: number;
  82504. /**
  82505. * Determine RBG output is premultiplied by alpha value.
  82506. */
  82507. preMultiplyAlpha: boolean;
  82508. private _opacityTexture;
  82509. opacityTexture: BABYLON.BaseTexture;
  82510. private _gridControl;
  82511. /**
  82512. * constructor
  82513. * @param name The name given to the material in order to identify it afterwards.
  82514. * @param scene The scene the material is used in.
  82515. */
  82516. constructor(name: string, scene: BABYLON.Scene);
  82517. /**
  82518. * Returns wehter or not the grid requires alpha blending.
  82519. */
  82520. needAlphaBlending(): boolean;
  82521. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82522. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82523. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82524. /**
  82525. * Dispose the material and its associated resources.
  82526. * @param forceDisposeEffect will also dispose the used effect when true
  82527. */
  82528. dispose(forceDisposeEffect?: boolean): void;
  82529. clone(name: string): GridMaterial;
  82530. serialize(): any;
  82531. getClassName(): string;
  82532. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  82533. }
  82534. }
  82535. declare module BABYLON {
  82536. /** @hidden */
  82537. export var lavaPixelShader: {
  82538. name: string;
  82539. shader: string;
  82540. };
  82541. }
  82542. declare module BABYLON {
  82543. /** @hidden */
  82544. export var lavaVertexShader: {
  82545. name: string;
  82546. shader: string;
  82547. };
  82548. }
  82549. declare module BABYLON {
  82550. export class LavaMaterial extends BABYLON.PushMaterial {
  82551. private _diffuseTexture;
  82552. diffuseTexture: BABYLON.BaseTexture;
  82553. noiseTexture: BABYLON.BaseTexture;
  82554. fogColor: BABYLON.Color3;
  82555. speed: number;
  82556. movingSpeed: number;
  82557. lowFrequencySpeed: number;
  82558. fogDensity: number;
  82559. private _lastTime;
  82560. diffuseColor: BABYLON.Color3;
  82561. private _disableLighting;
  82562. disableLighting: boolean;
  82563. private _unlit;
  82564. unlit: boolean;
  82565. private _maxSimultaneousLights;
  82566. maxSimultaneousLights: number;
  82567. private _scaledDiffuse;
  82568. constructor(name: string, scene: BABYLON.Scene);
  82569. needAlphaBlending(): boolean;
  82570. needAlphaTesting(): boolean;
  82571. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82572. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82573. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82574. getAnimatables(): BABYLON.IAnimatable[];
  82575. getActiveTextures(): BABYLON.BaseTexture[];
  82576. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82577. dispose(forceDisposeEffect?: boolean): void;
  82578. clone(name: string): LavaMaterial;
  82579. serialize(): any;
  82580. getClassName(): string;
  82581. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  82582. }
  82583. }
  82584. declare module BABYLON {
  82585. /** @hidden */
  82586. export var mixPixelShader: {
  82587. name: string;
  82588. shader: string;
  82589. };
  82590. }
  82591. declare module BABYLON {
  82592. /** @hidden */
  82593. export var mixVertexShader: {
  82594. name: string;
  82595. shader: string;
  82596. };
  82597. }
  82598. declare module BABYLON {
  82599. export class MixMaterial extends BABYLON.PushMaterial {
  82600. /**
  82601. * Mix textures
  82602. */
  82603. private _mixTexture1;
  82604. mixTexture1: BABYLON.BaseTexture;
  82605. private _mixTexture2;
  82606. mixTexture2: BABYLON.BaseTexture;
  82607. /**
  82608. * Diffuse textures
  82609. */
  82610. private _diffuseTexture1;
  82611. diffuseTexture1: BABYLON.Texture;
  82612. private _diffuseTexture2;
  82613. diffuseTexture2: BABYLON.Texture;
  82614. private _diffuseTexture3;
  82615. diffuseTexture3: BABYLON.Texture;
  82616. private _diffuseTexture4;
  82617. diffuseTexture4: BABYLON.Texture;
  82618. private _diffuseTexture5;
  82619. diffuseTexture5: BABYLON.Texture;
  82620. private _diffuseTexture6;
  82621. diffuseTexture6: BABYLON.Texture;
  82622. private _diffuseTexture7;
  82623. diffuseTexture7: BABYLON.Texture;
  82624. private _diffuseTexture8;
  82625. diffuseTexture8: BABYLON.Texture;
  82626. /**
  82627. * Uniforms
  82628. */
  82629. diffuseColor: BABYLON.Color3;
  82630. specularColor: BABYLON.Color3;
  82631. specularPower: number;
  82632. private _disableLighting;
  82633. disableLighting: boolean;
  82634. private _maxSimultaneousLights;
  82635. maxSimultaneousLights: number;
  82636. constructor(name: string, scene: BABYLON.Scene);
  82637. needAlphaBlending(): boolean;
  82638. needAlphaTesting(): boolean;
  82639. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82640. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82641. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82642. getAnimatables(): BABYLON.IAnimatable[];
  82643. getActiveTextures(): BABYLON.BaseTexture[];
  82644. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82645. dispose(forceDisposeEffect?: boolean): void;
  82646. clone(name: string): MixMaterial;
  82647. serialize(): any;
  82648. getClassName(): string;
  82649. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  82650. }
  82651. }
  82652. declare module BABYLON {
  82653. /** @hidden */
  82654. export var normalPixelShader: {
  82655. name: string;
  82656. shader: string;
  82657. };
  82658. }
  82659. declare module BABYLON {
  82660. /** @hidden */
  82661. export var normalVertexShader: {
  82662. name: string;
  82663. shader: string;
  82664. };
  82665. }
  82666. declare module BABYLON {
  82667. export class NormalMaterial extends BABYLON.PushMaterial {
  82668. private _diffuseTexture;
  82669. diffuseTexture: BABYLON.BaseTexture;
  82670. diffuseColor: BABYLON.Color3;
  82671. private _disableLighting;
  82672. disableLighting: boolean;
  82673. private _maxSimultaneousLights;
  82674. maxSimultaneousLights: number;
  82675. constructor(name: string, scene: BABYLON.Scene);
  82676. needAlphaBlending(): boolean;
  82677. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82678. needAlphaTesting(): boolean;
  82679. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82680. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82681. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82682. getAnimatables(): BABYLON.IAnimatable[];
  82683. getActiveTextures(): BABYLON.BaseTexture[];
  82684. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82685. dispose(forceDisposeEffect?: boolean): void;
  82686. clone(name: string): NormalMaterial;
  82687. serialize(): any;
  82688. getClassName(): string;
  82689. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  82690. }
  82691. }
  82692. declare module BABYLON {
  82693. /** @hidden */
  82694. export var shadowOnlyPixelShader: {
  82695. name: string;
  82696. shader: string;
  82697. };
  82698. }
  82699. declare module BABYLON {
  82700. /** @hidden */
  82701. export var shadowOnlyVertexShader: {
  82702. name: string;
  82703. shader: string;
  82704. };
  82705. }
  82706. declare module BABYLON {
  82707. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  82708. private _activeLight;
  82709. private _needAlphaBlending;
  82710. constructor(name: string, scene: BABYLON.Scene);
  82711. shadowColor: BABYLON.Color3;
  82712. needAlphaBlending(): boolean;
  82713. needAlphaTesting(): boolean;
  82714. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82715. get activeLight(): BABYLON.IShadowLight;
  82716. set activeLight(light: BABYLON.IShadowLight);
  82717. private _getFirstShadowLightForMesh;
  82718. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82719. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82720. clone(name: string): ShadowOnlyMaterial;
  82721. serialize(): any;
  82722. getClassName(): string;
  82723. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  82724. }
  82725. }
  82726. declare module BABYLON {
  82727. /** @hidden */
  82728. export var simplePixelShader: {
  82729. name: string;
  82730. shader: string;
  82731. };
  82732. }
  82733. declare module BABYLON {
  82734. /** @hidden */
  82735. export var simpleVertexShader: {
  82736. name: string;
  82737. shader: string;
  82738. };
  82739. }
  82740. declare module BABYLON {
  82741. export class SimpleMaterial extends BABYLON.PushMaterial {
  82742. private _diffuseTexture;
  82743. diffuseTexture: BABYLON.BaseTexture;
  82744. diffuseColor: BABYLON.Color3;
  82745. private _disableLighting;
  82746. disableLighting: boolean;
  82747. private _maxSimultaneousLights;
  82748. maxSimultaneousLights: number;
  82749. constructor(name: string, scene: BABYLON.Scene);
  82750. needAlphaBlending(): boolean;
  82751. needAlphaTesting(): boolean;
  82752. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82753. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82754. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82755. getAnimatables(): BABYLON.IAnimatable[];
  82756. getActiveTextures(): BABYLON.BaseTexture[];
  82757. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82758. dispose(forceDisposeEffect?: boolean): void;
  82759. clone(name: string): SimpleMaterial;
  82760. serialize(): any;
  82761. getClassName(): string;
  82762. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  82763. }
  82764. }
  82765. declare module BABYLON {
  82766. /** @hidden */
  82767. export var skyPixelShader: {
  82768. name: string;
  82769. shader: string;
  82770. };
  82771. }
  82772. declare module BABYLON {
  82773. /** @hidden */
  82774. export var skyVertexShader: {
  82775. name: string;
  82776. shader: string;
  82777. };
  82778. }
  82779. declare module BABYLON {
  82780. /**
  82781. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  82782. * @see https://doc.babylonjs.com/extensions/sky
  82783. */
  82784. export class SkyMaterial extends BABYLON.PushMaterial {
  82785. /**
  82786. * Defines the overall luminance of sky in interval ]0, 1[.
  82787. */
  82788. luminance: number;
  82789. /**
  82790. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  82791. */
  82792. turbidity: number;
  82793. /**
  82794. * Defines the sky appearance (light intensity).
  82795. */
  82796. rayleigh: number;
  82797. /**
  82798. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  82799. */
  82800. mieCoefficient: number;
  82801. /**
  82802. * Defines the amount of haze particles following the Mie scattering theory.
  82803. */
  82804. mieDirectionalG: number;
  82805. /**
  82806. * Defines the distance of the sun according to the active scene camera.
  82807. */
  82808. distance: number;
  82809. /**
  82810. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  82811. * "inclined".
  82812. */
  82813. inclination: number;
  82814. /**
  82815. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  82816. * an object direction and a reference direction.
  82817. */
  82818. azimuth: number;
  82819. /**
  82820. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  82821. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  82822. */
  82823. sunPosition: BABYLON.Vector3;
  82824. /**
  82825. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  82826. * .sunPosition property.
  82827. */
  82828. useSunPosition: boolean;
  82829. /**
  82830. * Defines an offset vector used to get a horizon offset.
  82831. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  82832. */
  82833. cameraOffset: BABYLON.Vector3;
  82834. private _cameraPosition;
  82835. /**
  82836. * Instantiates a new sky material.
  82837. * This material allows to create dynamic and texture free
  82838. * effects for skyboxes by taking care of the atmosphere state.
  82839. * @see https://doc.babylonjs.com/extensions/sky
  82840. * @param name Define the name of the material in the scene
  82841. * @param scene Define the scene the material belong to
  82842. */
  82843. constructor(name: string, scene: BABYLON.Scene);
  82844. /**
  82845. * Specifies if the material will require alpha blending
  82846. * @returns a boolean specifying if alpha blending is needed
  82847. */
  82848. needAlphaBlending(): boolean;
  82849. /**
  82850. * Specifies if this material should be rendered in alpha test mode
  82851. * @returns false as the sky material doesn't need alpha testing.
  82852. */
  82853. needAlphaTesting(): boolean;
  82854. /**
  82855. * Get the texture used for alpha test purpose.
  82856. * @returns null as the sky material has no texture.
  82857. */
  82858. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82859. /**
  82860. * Get if the submesh is ready to be used and all its information available.
  82861. * Child classes can use it to update shaders
  82862. * @param mesh defines the mesh to check
  82863. * @param subMesh defines which submesh to check
  82864. * @param useInstances specifies that instances should be used
  82865. * @returns a boolean indicating that the submesh is ready or not
  82866. */
  82867. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82868. /**
  82869. * Binds the submesh to this material by preparing the effect and shader to draw
  82870. * @param world defines the world transformation matrix
  82871. * @param mesh defines the mesh containing the submesh
  82872. * @param subMesh defines the submesh to bind the material to
  82873. */
  82874. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82875. /**
  82876. * Get the list of animatables in the material.
  82877. * @returns the list of animatables object used in the material
  82878. */
  82879. getAnimatables(): BABYLON.IAnimatable[];
  82880. /**
  82881. * Disposes the material
  82882. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82883. */
  82884. dispose(forceDisposeEffect?: boolean): void;
  82885. /**
  82886. * Makes a duplicate of the material, and gives it a new name
  82887. * @param name defines the new name for the duplicated material
  82888. * @returns the cloned material
  82889. */
  82890. clone(name: string): SkyMaterial;
  82891. /**
  82892. * Serializes this material in a JSON representation
  82893. * @returns the serialized material object
  82894. */
  82895. serialize(): any;
  82896. /**
  82897. * Gets the current class name of the material e.g. "SkyMaterial"
  82898. * Mainly use in serialization.
  82899. * @returns the class name
  82900. */
  82901. getClassName(): string;
  82902. /**
  82903. * Creates a sky material from parsed material data
  82904. * @param source defines the JSON representation of the material
  82905. * @param scene defines the hosting scene
  82906. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  82907. * @returns a new sky material
  82908. */
  82909. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  82910. }
  82911. }
  82912. declare module BABYLON {
  82913. /** @hidden */
  82914. export var terrainPixelShader: {
  82915. name: string;
  82916. shader: string;
  82917. };
  82918. }
  82919. declare module BABYLON {
  82920. /** @hidden */
  82921. export var terrainVertexShader: {
  82922. name: string;
  82923. shader: string;
  82924. };
  82925. }
  82926. declare module BABYLON {
  82927. export class TerrainMaterial extends BABYLON.PushMaterial {
  82928. private _mixTexture;
  82929. mixTexture: BABYLON.BaseTexture;
  82930. private _diffuseTexture1;
  82931. diffuseTexture1: BABYLON.Texture;
  82932. private _diffuseTexture2;
  82933. diffuseTexture2: BABYLON.Texture;
  82934. private _diffuseTexture3;
  82935. diffuseTexture3: BABYLON.Texture;
  82936. private _bumpTexture1;
  82937. bumpTexture1: BABYLON.Texture;
  82938. private _bumpTexture2;
  82939. bumpTexture2: BABYLON.Texture;
  82940. private _bumpTexture3;
  82941. bumpTexture3: BABYLON.Texture;
  82942. diffuseColor: BABYLON.Color3;
  82943. specularColor: BABYLON.Color3;
  82944. specularPower: number;
  82945. private _disableLighting;
  82946. disableLighting: boolean;
  82947. private _maxSimultaneousLights;
  82948. maxSimultaneousLights: number;
  82949. constructor(name: string, scene: BABYLON.Scene);
  82950. needAlphaBlending(): boolean;
  82951. needAlphaTesting(): boolean;
  82952. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82953. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82954. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82955. getAnimatables(): BABYLON.IAnimatable[];
  82956. getActiveTextures(): BABYLON.BaseTexture[];
  82957. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82958. dispose(forceDisposeEffect?: boolean): void;
  82959. clone(name: string): TerrainMaterial;
  82960. serialize(): any;
  82961. getClassName(): string;
  82962. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  82963. }
  82964. }
  82965. declare module BABYLON {
  82966. /** @hidden */
  82967. export var triplanarPixelShader: {
  82968. name: string;
  82969. shader: string;
  82970. };
  82971. }
  82972. declare module BABYLON {
  82973. /** @hidden */
  82974. export var triplanarVertexShader: {
  82975. name: string;
  82976. shader: string;
  82977. };
  82978. }
  82979. declare module BABYLON {
  82980. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  82981. mixTexture: BABYLON.BaseTexture;
  82982. private _diffuseTextureX;
  82983. diffuseTextureX: BABYLON.BaseTexture;
  82984. private _diffuseTextureY;
  82985. diffuseTextureY: BABYLON.BaseTexture;
  82986. private _diffuseTextureZ;
  82987. diffuseTextureZ: BABYLON.BaseTexture;
  82988. private _normalTextureX;
  82989. normalTextureX: BABYLON.BaseTexture;
  82990. private _normalTextureY;
  82991. normalTextureY: BABYLON.BaseTexture;
  82992. private _normalTextureZ;
  82993. normalTextureZ: BABYLON.BaseTexture;
  82994. tileSize: number;
  82995. diffuseColor: BABYLON.Color3;
  82996. specularColor: BABYLON.Color3;
  82997. specularPower: number;
  82998. private _disableLighting;
  82999. disableLighting: boolean;
  83000. private _maxSimultaneousLights;
  83001. maxSimultaneousLights: number;
  83002. constructor(name: string, scene: BABYLON.Scene);
  83003. needAlphaBlending(): boolean;
  83004. needAlphaTesting(): boolean;
  83005. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83006. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83007. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83008. getAnimatables(): BABYLON.IAnimatable[];
  83009. getActiveTextures(): BABYLON.BaseTexture[];
  83010. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83011. dispose(forceDisposeEffect?: boolean): void;
  83012. clone(name: string): TriPlanarMaterial;
  83013. serialize(): any;
  83014. getClassName(): string;
  83015. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  83016. }
  83017. }
  83018. declare module BABYLON {
  83019. /** @hidden */
  83020. export var waterPixelShader: {
  83021. name: string;
  83022. shader: string;
  83023. };
  83024. }
  83025. declare module BABYLON {
  83026. /** @hidden */
  83027. export var waterVertexShader: {
  83028. name: string;
  83029. shader: string;
  83030. };
  83031. }
  83032. declare module BABYLON {
  83033. export class WaterMaterial extends BABYLON.PushMaterial {
  83034. renderTargetSize: BABYLON.Vector2;
  83035. private _bumpTexture;
  83036. bumpTexture: BABYLON.BaseTexture;
  83037. diffuseColor: BABYLON.Color3;
  83038. specularColor: BABYLON.Color3;
  83039. specularPower: number;
  83040. private _disableLighting;
  83041. disableLighting: boolean;
  83042. private _maxSimultaneousLights;
  83043. maxSimultaneousLights: number;
  83044. /**
  83045. * @param {number}: Represents the wind force
  83046. */
  83047. windForce: number;
  83048. /**
  83049. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  83050. */
  83051. windDirection: BABYLON.Vector2;
  83052. /**
  83053. * @param {number}: Wave height, represents the height of the waves
  83054. */
  83055. waveHeight: number;
  83056. /**
  83057. * @param {number}: Bump height, represents the bump height related to the bump map
  83058. */
  83059. bumpHeight: number;
  83060. /**
  83061. * @param {boolean}: Add a smaller moving bump to less steady waves.
  83062. */
  83063. private _bumpSuperimpose;
  83064. bumpSuperimpose: boolean;
  83065. /**
  83066. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83067. */
  83068. private _fresnelSeparate;
  83069. fresnelSeparate: boolean;
  83070. /**
  83071. * @param {boolean}: bump Waves modify the reflection.
  83072. */
  83073. private _bumpAffectsReflection;
  83074. bumpAffectsReflection: boolean;
  83075. /**
  83076. * @param {number}: The water color blended with the refraction (near)
  83077. */
  83078. waterColor: BABYLON.Color3;
  83079. /**
  83080. * @param {number}: The blend factor related to the water color
  83081. */
  83082. colorBlendFactor: number;
  83083. /**
  83084. * @param {number}: The water color blended with the reflection (far)
  83085. */
  83086. waterColor2: BABYLON.Color3;
  83087. /**
  83088. * @param {number}: The blend factor related to the water color (reflection, far)
  83089. */
  83090. colorBlendFactor2: number;
  83091. /**
  83092. * @param {number}: Represents the maximum length of a wave
  83093. */
  83094. waveLength: number;
  83095. /**
  83096. * @param {number}: Defines the waves speed
  83097. */
  83098. waveSpeed: number;
  83099. /**
  83100. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83101. * will avoid calculating useless pixels in the pixel shader of the water material.
  83102. */
  83103. disableClipPlane: boolean;
  83104. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83105. private _mesh;
  83106. private _refractionRTT;
  83107. private _reflectionRTT;
  83108. private _reflectionTransform;
  83109. private _lastTime;
  83110. private _lastDeltaTime;
  83111. private _useLogarithmicDepth;
  83112. private _waitingRenderList;
  83113. private _imageProcessingConfiguration;
  83114. private _imageProcessingObserver;
  83115. /**
  83116. * Gets a boolean indicating that current material needs to register RTT
  83117. */
  83118. get hasRenderTargetTextures(): boolean;
  83119. /**
  83120. * Constructor
  83121. */
  83122. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83123. get useLogarithmicDepth(): boolean;
  83124. set useLogarithmicDepth(value: boolean);
  83125. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83126. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83127. addToRenderList(node: any): void;
  83128. enableRenderTargets(enable: boolean): void;
  83129. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83130. get renderTargetsEnabled(): boolean;
  83131. needAlphaBlending(): boolean;
  83132. needAlphaTesting(): boolean;
  83133. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83134. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83135. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83136. private _createRenderTargets;
  83137. getAnimatables(): BABYLON.IAnimatable[];
  83138. getActiveTextures(): BABYLON.BaseTexture[];
  83139. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83140. dispose(forceDisposeEffect?: boolean): void;
  83141. clone(name: string): WaterMaterial;
  83142. serialize(): any;
  83143. getClassName(): string;
  83144. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83145. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83146. }
  83147. }
  83148. declare module BABYLON {
  83149. /** @hidden */
  83150. export var asciiartPixelShader: {
  83151. name: string;
  83152. shader: string;
  83153. };
  83154. }
  83155. declare module BABYLON {
  83156. /**
  83157. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83158. *
  83159. * It basically takes care rendering the font front the given font size to a texture.
  83160. * This is used later on in the postprocess.
  83161. */
  83162. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83163. private _font;
  83164. private _text;
  83165. private _charSize;
  83166. /**
  83167. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83168. */
  83169. get charSize(): number;
  83170. /**
  83171. * Create a new instance of the Ascii Art FontTexture class
  83172. * @param name the name of the texture
  83173. * @param font the font to use, use the W3C CSS notation
  83174. * @param text the caracter set to use in the rendering.
  83175. * @param scene the scene that owns the texture
  83176. */
  83177. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83178. /**
  83179. * Gets the max char width of a font.
  83180. * @param font the font to use, use the W3C CSS notation
  83181. * @return the max char width
  83182. */
  83183. private getFontWidth;
  83184. /**
  83185. * Gets the max char height of a font.
  83186. * @param font the font to use, use the W3C CSS notation
  83187. * @return the max char height
  83188. */
  83189. private getFontHeight;
  83190. /**
  83191. * Clones the current AsciiArtTexture.
  83192. * @return the clone of the texture.
  83193. */
  83194. clone(): AsciiArtFontTexture;
  83195. /**
  83196. * Parses a json object representing the texture and returns an instance of it.
  83197. * @param source the source JSON representation
  83198. * @param scene the scene to create the texture for
  83199. * @return the parsed texture
  83200. */
  83201. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83202. }
  83203. /**
  83204. * Option available in the Ascii Art Post Process.
  83205. */
  83206. export interface IAsciiArtPostProcessOptions {
  83207. /**
  83208. * The font to use following the w3c font definition.
  83209. */
  83210. font?: string;
  83211. /**
  83212. * The character set to use in the postprocess.
  83213. */
  83214. characterSet?: string;
  83215. /**
  83216. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83217. * This number is defined between 0 and 1;
  83218. */
  83219. mixToTile?: number;
  83220. /**
  83221. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83222. * This number is defined between 0 and 1;
  83223. */
  83224. mixToNormal?: number;
  83225. }
  83226. /**
  83227. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83228. *
  83229. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83230. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83231. */
  83232. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83233. /**
  83234. * The font texture used to render the char in the post process.
  83235. */
  83236. private _asciiArtFontTexture;
  83237. /**
  83238. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83239. * This number is defined between 0 and 1;
  83240. */
  83241. mixToTile: number;
  83242. /**
  83243. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83244. * This number is defined between 0 and 1;
  83245. */
  83246. mixToNormal: number;
  83247. /**
  83248. * Instantiates a new Ascii Art Post Process.
  83249. * @param name the name to give to the postprocess
  83250. * @camera the camera to apply the post process to.
  83251. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83252. */
  83253. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83254. }
  83255. }
  83256. declare module BABYLON {
  83257. /** @hidden */
  83258. export var digitalrainPixelShader: {
  83259. name: string;
  83260. shader: string;
  83261. };
  83262. }
  83263. declare module BABYLON {
  83264. /**
  83265. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  83266. *
  83267. * It basically takes care rendering the font front the given font size to a texture.
  83268. * This is used later on in the postprocess.
  83269. */
  83270. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  83271. private _font;
  83272. private _text;
  83273. private _charSize;
  83274. /**
  83275. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83276. */
  83277. get charSize(): number;
  83278. /**
  83279. * Create a new instance of the Digital Rain FontTexture class
  83280. * @param name the name of the texture
  83281. * @param font the font to use, use the W3C CSS notation
  83282. * @param text the caracter set to use in the rendering.
  83283. * @param scene the scene that owns the texture
  83284. */
  83285. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83286. /**
  83287. * Gets the max char width of a font.
  83288. * @param font the font to use, use the W3C CSS notation
  83289. * @return the max char width
  83290. */
  83291. private getFontWidth;
  83292. /**
  83293. * Gets the max char height of a font.
  83294. * @param font the font to use, use the W3C CSS notation
  83295. * @return the max char height
  83296. */
  83297. private getFontHeight;
  83298. /**
  83299. * Clones the current DigitalRainFontTexture.
  83300. * @return the clone of the texture.
  83301. */
  83302. clone(): DigitalRainFontTexture;
  83303. /**
  83304. * Parses a json object representing the texture and returns an instance of it.
  83305. * @param source the source JSON representation
  83306. * @param scene the scene to create the texture for
  83307. * @return the parsed texture
  83308. */
  83309. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  83310. }
  83311. /**
  83312. * Option available in the Digital Rain Post Process.
  83313. */
  83314. export interface IDigitalRainPostProcessOptions {
  83315. /**
  83316. * The font to use following the w3c font definition.
  83317. */
  83318. font?: string;
  83319. /**
  83320. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83321. * This number is defined between 0 and 1;
  83322. */
  83323. mixToTile?: number;
  83324. /**
  83325. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83326. * This number is defined between 0 and 1;
  83327. */
  83328. mixToNormal?: number;
  83329. }
  83330. /**
  83331. * DigitalRainPostProcess helps rendering everithing in digital rain.
  83332. *
  83333. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83334. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  83335. */
  83336. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  83337. /**
  83338. * The font texture used to render the char in the post process.
  83339. */
  83340. private _digitalRainFontTexture;
  83341. /**
  83342. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83343. * This number is defined between 0 and 1;
  83344. */
  83345. mixToTile: number;
  83346. /**
  83347. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83348. * This number is defined between 0 and 1;
  83349. */
  83350. mixToNormal: number;
  83351. /**
  83352. * Instantiates a new Digital Rain Post Process.
  83353. * @param name the name to give to the postprocess
  83354. * @camera the camera to apply the post process to.
  83355. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  83356. */
  83357. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  83358. }
  83359. }
  83360. declare module BABYLON {
  83361. /** @hidden */
  83362. export var brickProceduralTexturePixelShader: {
  83363. name: string;
  83364. shader: string;
  83365. };
  83366. }
  83367. declare module BABYLON {
  83368. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  83369. private _numberOfBricksHeight;
  83370. private _numberOfBricksWidth;
  83371. private _jointColor;
  83372. private _brickColor;
  83373. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83374. updateShaderUniforms(): void;
  83375. get numberOfBricksHeight(): number;
  83376. set numberOfBricksHeight(value: number);
  83377. get numberOfBricksWidth(): number;
  83378. set numberOfBricksWidth(value: number);
  83379. get jointColor(): BABYLON.Color3;
  83380. set jointColor(value: BABYLON.Color3);
  83381. get brickColor(): BABYLON.Color3;
  83382. set brickColor(value: BABYLON.Color3);
  83383. /**
  83384. * Serializes this brick procedural texture
  83385. * @returns a serialized brick procedural texture object
  83386. */
  83387. serialize(): any;
  83388. /**
  83389. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  83390. * @param parsedTexture defines parsed texture data
  83391. * @param scene defines the current scene
  83392. * @param rootUrl defines the root URL containing brick procedural texture information
  83393. * @returns a parsed Brick Procedural BABYLON.Texture
  83394. */
  83395. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  83396. }
  83397. }
  83398. declare module BABYLON {
  83399. /** @hidden */
  83400. export var cloudProceduralTexturePixelShader: {
  83401. name: string;
  83402. shader: string;
  83403. };
  83404. }
  83405. declare module BABYLON {
  83406. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  83407. private _skyColor;
  83408. private _cloudColor;
  83409. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83410. updateShaderUniforms(): void;
  83411. get skyColor(): BABYLON.Color4;
  83412. set skyColor(value: BABYLON.Color4);
  83413. get cloudColor(): BABYLON.Color4;
  83414. set cloudColor(value: BABYLON.Color4);
  83415. /**
  83416. * Serializes this cloud procedural texture
  83417. * @returns a serialized cloud procedural texture object
  83418. */
  83419. serialize(): any;
  83420. /**
  83421. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  83422. * @param parsedTexture defines parsed texture data
  83423. * @param scene defines the current scene
  83424. * @param rootUrl defines the root URL containing cloud procedural texture information
  83425. * @returns a parsed Cloud Procedural BABYLON.Texture
  83426. */
  83427. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  83428. }
  83429. }
  83430. declare module BABYLON {
  83431. /** @hidden */
  83432. export var fireProceduralTexturePixelShader: {
  83433. name: string;
  83434. shader: string;
  83435. };
  83436. }
  83437. declare module BABYLON {
  83438. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  83439. private _time;
  83440. private _speed;
  83441. private _autoGenerateTime;
  83442. private _fireColors;
  83443. private _alphaThreshold;
  83444. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83445. updateShaderUniforms(): void;
  83446. render(useCameraPostProcess?: boolean): void;
  83447. static get PurpleFireColors(): BABYLON.Color3[];
  83448. static get GreenFireColors(): BABYLON.Color3[];
  83449. static get RedFireColors(): BABYLON.Color3[];
  83450. static get BlueFireColors(): BABYLON.Color3[];
  83451. get autoGenerateTime(): boolean;
  83452. set autoGenerateTime(value: boolean);
  83453. get fireColors(): BABYLON.Color3[];
  83454. set fireColors(value: BABYLON.Color3[]);
  83455. get time(): number;
  83456. set time(value: number);
  83457. get speed(): BABYLON.Vector2;
  83458. set speed(value: BABYLON.Vector2);
  83459. get alphaThreshold(): number;
  83460. set alphaThreshold(value: number);
  83461. /**
  83462. * Serializes this fire procedural texture
  83463. * @returns a serialized fire procedural texture object
  83464. */
  83465. serialize(): any;
  83466. /**
  83467. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  83468. * @param parsedTexture defines parsed texture data
  83469. * @param scene defines the current scene
  83470. * @param rootUrl defines the root URL containing fire procedural texture information
  83471. * @returns a parsed Fire Procedural BABYLON.Texture
  83472. */
  83473. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  83474. }
  83475. }
  83476. declare module BABYLON {
  83477. /** @hidden */
  83478. export var grassProceduralTexturePixelShader: {
  83479. name: string;
  83480. shader: string;
  83481. };
  83482. }
  83483. declare module BABYLON {
  83484. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  83485. private _grassColors;
  83486. private _groundColor;
  83487. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83488. updateShaderUniforms(): void;
  83489. get grassColors(): BABYLON.Color3[];
  83490. set grassColors(value: BABYLON.Color3[]);
  83491. get groundColor(): BABYLON.Color3;
  83492. set groundColor(value: BABYLON.Color3);
  83493. /**
  83494. * Serializes this grass procedural texture
  83495. * @returns a serialized grass procedural texture object
  83496. */
  83497. serialize(): any;
  83498. /**
  83499. * Creates a Grass Procedural BABYLON.Texture from parsed grass 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 grass procedural texture information
  83503. * @returns a parsed Grass Procedural BABYLON.Texture
  83504. */
  83505. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  83506. }
  83507. }
  83508. declare module BABYLON {
  83509. /** @hidden */
  83510. export var marbleProceduralTexturePixelShader: {
  83511. name: string;
  83512. shader: string;
  83513. };
  83514. }
  83515. declare module BABYLON {
  83516. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  83517. private _numberOfTilesHeight;
  83518. private _numberOfTilesWidth;
  83519. private _amplitude;
  83520. private _jointColor;
  83521. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83522. updateShaderUniforms(): void;
  83523. get numberOfTilesHeight(): number;
  83524. set numberOfTilesHeight(value: number);
  83525. get amplitude(): number;
  83526. set amplitude(value: number);
  83527. get numberOfTilesWidth(): number;
  83528. set numberOfTilesWidth(value: number);
  83529. get jointColor(): BABYLON.Color3;
  83530. set jointColor(value: BABYLON.Color3);
  83531. /**
  83532. * Serializes this marble procedural texture
  83533. * @returns a serialized marble procedural texture object
  83534. */
  83535. serialize(): any;
  83536. /**
  83537. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  83538. * @param parsedTexture defines parsed texture data
  83539. * @param scene defines the current scene
  83540. * @param rootUrl defines the root URL containing marble procedural texture information
  83541. * @returns a parsed Marble Procedural BABYLON.Texture
  83542. */
  83543. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  83544. }
  83545. }
  83546. declare module BABYLON {
  83547. /** @hidden */
  83548. export var normalMapProceduralTexturePixelShader: {
  83549. name: string;
  83550. shader: string;
  83551. };
  83552. }
  83553. declare module BABYLON {
  83554. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  83555. private _baseTexture;
  83556. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83557. updateShaderUniforms(): void;
  83558. render(useCameraPostProcess?: boolean): void;
  83559. resize(size: any, generateMipMaps: any): void;
  83560. get baseTexture(): BABYLON.Texture;
  83561. set baseTexture(texture: BABYLON.Texture);
  83562. /**
  83563. * Serializes this normal map procedural texture
  83564. * @returns a serialized normal map procedural texture object
  83565. */
  83566. serialize(): any;
  83567. /**
  83568. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  83569. * @param parsedTexture defines parsed texture data
  83570. * @param scene defines the current scene
  83571. * @param rootUrl defines the root URL containing normal map procedural texture information
  83572. * @returns a parsed Normal Map Procedural BABYLON.Texture
  83573. */
  83574. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  83575. }
  83576. }
  83577. declare module BABYLON {
  83578. /** @hidden */
  83579. export var perlinNoiseProceduralTexturePixelShader: {
  83580. name: string;
  83581. shader: string;
  83582. };
  83583. }
  83584. declare module BABYLON {
  83585. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  83586. time: number;
  83587. timeScale: number;
  83588. translationSpeed: number;
  83589. private _currentTranslation;
  83590. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83591. updateShaderUniforms(): void;
  83592. render(useCameraPostProcess?: boolean): void;
  83593. resize(size: any, generateMipMaps: any): void;
  83594. /**
  83595. * Serializes this perlin noise procedural texture
  83596. * @returns a serialized perlin noise procedural texture object
  83597. */
  83598. serialize(): any;
  83599. /**
  83600. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  83601. * @param parsedTexture defines parsed texture data
  83602. * @param scene defines the current scene
  83603. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  83604. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  83605. */
  83606. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  83607. }
  83608. }
  83609. declare module BABYLON {
  83610. /** @hidden */
  83611. export var roadProceduralTexturePixelShader: {
  83612. name: string;
  83613. shader: string;
  83614. };
  83615. }
  83616. declare module BABYLON {
  83617. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  83618. private _roadColor;
  83619. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83620. updateShaderUniforms(): void;
  83621. get roadColor(): BABYLON.Color3;
  83622. set roadColor(value: BABYLON.Color3);
  83623. /**
  83624. * Serializes this road procedural texture
  83625. * @returns a serialized road procedural texture object
  83626. */
  83627. serialize(): any;
  83628. /**
  83629. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  83630. * @param parsedTexture defines parsed texture data
  83631. * @param scene defines the current scene
  83632. * @param rootUrl defines the root URL containing road procedural texture information
  83633. * @returns a parsed Road Procedural BABYLON.Texture
  83634. */
  83635. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  83636. }
  83637. }
  83638. declare module BABYLON {
  83639. /** @hidden */
  83640. export var starfieldProceduralTexturePixelShader: {
  83641. name: string;
  83642. shader: string;
  83643. };
  83644. }
  83645. declare module BABYLON {
  83646. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  83647. private _time;
  83648. private _alpha;
  83649. private _beta;
  83650. private _zoom;
  83651. private _formuparam;
  83652. private _stepsize;
  83653. private _tile;
  83654. private _brightness;
  83655. private _darkmatter;
  83656. private _distfading;
  83657. private _saturation;
  83658. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83659. updateShaderUniforms(): void;
  83660. get time(): number;
  83661. set time(value: number);
  83662. get alpha(): number;
  83663. set alpha(value: number);
  83664. get beta(): number;
  83665. set beta(value: number);
  83666. get formuparam(): number;
  83667. set formuparam(value: number);
  83668. get stepsize(): number;
  83669. set stepsize(value: number);
  83670. get zoom(): number;
  83671. set zoom(value: number);
  83672. get tile(): number;
  83673. set tile(value: number);
  83674. get brightness(): number;
  83675. set brightness(value: number);
  83676. get darkmatter(): number;
  83677. set darkmatter(value: number);
  83678. get distfading(): number;
  83679. set distfading(value: number);
  83680. get saturation(): number;
  83681. set saturation(value: number);
  83682. /**
  83683. * Serializes this starfield procedural texture
  83684. * @returns a serialized starfield procedural texture object
  83685. */
  83686. serialize(): any;
  83687. /**
  83688. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  83689. * @param parsedTexture defines parsed texture data
  83690. * @param scene defines the current scene
  83691. * @param rootUrl defines the root URL containing startfield procedural texture information
  83692. * @returns a parsed Starfield Procedural BABYLON.Texture
  83693. */
  83694. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  83695. }
  83696. }
  83697. declare module BABYLON {
  83698. /** @hidden */
  83699. export var woodProceduralTexturePixelShader: {
  83700. name: string;
  83701. shader: string;
  83702. };
  83703. }
  83704. declare module BABYLON {
  83705. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  83706. private _ampScale;
  83707. private _woodColor;
  83708. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83709. updateShaderUniforms(): void;
  83710. get ampScale(): number;
  83711. set ampScale(value: number);
  83712. get woodColor(): BABYLON.Color3;
  83713. set woodColor(value: BABYLON.Color3);
  83714. /**
  83715. * Serializes this wood procedural texture
  83716. * @returns a serialized wood procedural texture object
  83717. */
  83718. serialize(): any;
  83719. /**
  83720. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  83721. * @param parsedTexture defines parsed texture data
  83722. * @param scene defines the current scene
  83723. * @param rootUrl defines the root URL containing wood procedural texture information
  83724. * @returns a parsed Wood Procedural BABYLON.Texture
  83725. */
  83726. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  83727. }
  83728. }